Bug Summary

File:out/../test/cctest/test-api.cc
Location:line 16629, column 5
Description:Null pointer passed as an argument to a 'nonnull' parameter

Annotated Source Code

1// Copyright 2012 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include <climits>
29#include <csignal>
30#include <map>
31#include <string>
32
33#include "test/cctest/test-api.h"
34
35#if V8_OS_POSIX1
36#include <unistd.h> // NOLINT
37#endif
38
39#include "include/v8-util.h"
40#include "src/api.h"
41#include "src/arguments.h"
42#include "src/base/platform/platform.h"
43#include "src/base/smart-pointers.h"
44#include "src/compilation-cache.h"
45#include "src/debug/debug.h"
46#include "src/execution.h"
47#include "src/futex-emulation.h"
48#include "src/objects.h"
49#include "src/parsing/parser.h"
50#include "src/unicode-inl.h"
51#include "src/utils.h"
52#include "src/vm-state.h"
53#include "test/cctest/heap/heap-tester.h"
54#include "test/cctest/heap/utils-inl.h"
55
56static const bool kLogThreading = false;
57
58using ::v8::Boolean;
59using ::v8::BooleanObject;
60using ::v8::Context;
61using ::v8::Extension;
62using ::v8::Function;
63using ::v8::FunctionTemplate;
64using ::v8::HandleScope;
65using ::v8::Local;
66using ::v8::Maybe;
67using ::v8::Message;
68using ::v8::MessageCallback;
69using ::v8::Name;
70using ::v8::None;
71using ::v8::Object;
72using ::v8::ObjectTemplate;
73using ::v8::Persistent;
74using ::v8::PropertyAttribute;
75using ::v8::Script;
76using ::v8::StackTrace;
77using ::v8::String;
78using ::v8::Symbol;
79using ::v8::TryCatch;
80using ::v8::Undefined;
81using ::v8::UniqueId;
82using ::v8::V8;
83using ::v8::Value;
84
85
86#define THREADED_PROFILED_TEST(Name)static void TestName(); static void TestNameWithProfiler(); CcTest
register_test_NameWithProfiler(TestNameWithProfiler, "../test/cctest/test-api.cc"
, "NameWithProfiler", __null, true, true); static void TestNameWithProfiler
() { RunWithProfiler(&TestName); } static void TestName()
; RegisterThreadedTest register_Name(TestName, "Name"); static
void TestName(); CcTest register_test_Name(TestName, "../test/cctest/test-api.cc"
, "Name", __null, true, true); static void TestName()
\
87 static void Test##Name(); \
88 TEST(Name##WithProfiler)static void TestName##WithProfiler(); CcTest register_test_Name
##WithProfiler(TestName##WithProfiler, "../test/cctest/test-api.cc"
, "Name##WithProfiler", __null, true, true); static void TestName
##WithProfiler()
{ \
89 RunWithProfiler(&Test##Name); \
90 } \
91 THREADED_TEST(Name)static void TestName(); RegisterThreadedTest register_Name(TestName
, "Name"); static void TestName(); CcTest register_test_Name(
TestName, "../test/cctest/test-api.cc", "Name", __null, true,
true); static void TestName()
92
93
94void RunWithProfiler(void (*test)()) {
95 LocalContext env;
96 v8::HandleScope scope(env->GetIsolate());
97 v8::Local<v8::String> profile_name = v8_str("my_profile1");
98 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
99
100 cpu_profiler->StartProfiling(profile_name);
101 (*test)();
102 reinterpret_cast<i::CpuProfiler*>(cpu_profiler)->DeleteAllProfiles();
103}
104
105
106static int signature_callback_count;
107static Local<Value> signature_expected_receiver;
108static void IncrementingSignatureCallback(
109 const v8::FunctionCallbackInfo<v8::Value>& args) {
110 ApiTestFuzzer::Fuzz();
111 signature_callback_count++;
112 CHECK(signature_expected_receiver->Equals(do { if ((__builtin_expect(!!(!(signature_expected_receiver->
Equals( args.GetIsolate()->GetCurrentContext(), args.Holder
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 115, "Check failed: %s.", "signature_expected_receiver->Equals( args.GetIsolate()->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
113 args.GetIsolate()->GetCurrentContext(),do { if ((__builtin_expect(!!(!(signature_expected_receiver->
Equals( args.GetIsolate()->GetCurrentContext(), args.Holder
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 115, "Check failed: %s.", "signature_expected_receiver->Equals( args.GetIsolate()->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
114 args.Holder())do { if ((__builtin_expect(!!(!(signature_expected_receiver->
Equals( args.GetIsolate()->GetCurrentContext(), args.Holder
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 115, "Check failed: %s.", "signature_expected_receiver->Equals( args.GetIsolate()->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
115 .FromJust())do { if ((__builtin_expect(!!(!(signature_expected_receiver->
Equals( args.GetIsolate()->GetCurrentContext(), args.Holder
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 115, "Check failed: %s.", "signature_expected_receiver->Equals( args.GetIsolate()->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
;
116 CHECK(signature_expected_receiver->Equals(do { if ((__builtin_expect(!!(!(signature_expected_receiver->
Equals( args.GetIsolate()->GetCurrentContext(), args.This(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 119, "Check failed: %s.", "signature_expected_receiver->Equals( args.GetIsolate()->GetCurrentContext(), args.This()) .FromJust()"
); } } while (0)
117 args.GetIsolate()->GetCurrentContext(),do { if ((__builtin_expect(!!(!(signature_expected_receiver->
Equals( args.GetIsolate()->GetCurrentContext(), args.This(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 119, "Check failed: %s.", "signature_expected_receiver->Equals( args.GetIsolate()->GetCurrentContext(), args.This()) .FromJust()"
); } } while (0)
118 args.This())do { if ((__builtin_expect(!!(!(signature_expected_receiver->
Equals( args.GetIsolate()->GetCurrentContext(), args.This(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 119, "Check failed: %s.", "signature_expected_receiver->Equals( args.GetIsolate()->GetCurrentContext(), args.This()) .FromJust()"
); } } while (0)
119 .FromJust())do { if ((__builtin_expect(!!(!(signature_expected_receiver->
Equals( args.GetIsolate()->GetCurrentContext(), args.This(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 119, "Check failed: %s.", "signature_expected_receiver->Equals( args.GetIsolate()->GetCurrentContext(), args.This()) .FromJust()"
); } } while (0)
;
120 v8::Local<v8::Array> result =
121 v8::Array::New(args.GetIsolate(), args.Length());
122 for (int i = 0; i < args.Length(); i++) {
123 CHECK(result->Set(args.GetIsolate()->GetCurrentContext(),do { if ((__builtin_expect(!!(!(result->Set(args.GetIsolate
()->GetCurrentContext(), v8::Integer::New(args.GetIsolate(
), i), args[i]) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 125, "Check failed: %s.", "result->Set(args.GetIsolate()->GetCurrentContext(), v8::Integer::New(args.GetIsolate(), i), args[i]) .FromJust()"
); } } while (0)
124 v8::Integer::New(args.GetIsolate(), i), args[i])do { if ((__builtin_expect(!!(!(result->Set(args.GetIsolate
()->GetCurrentContext(), v8::Integer::New(args.GetIsolate(
), i), args[i]) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 125, "Check failed: %s.", "result->Set(args.GetIsolate()->GetCurrentContext(), v8::Integer::New(args.GetIsolate(), i), args[i]) .FromJust()"
); } } while (0)
125 .FromJust())do { if ((__builtin_expect(!!(!(result->Set(args.GetIsolate
()->GetCurrentContext(), v8::Integer::New(args.GetIsolate(
), i), args[i]) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 125, "Check failed: %s.", "result->Set(args.GetIsolate()->GetCurrentContext(), v8::Integer::New(args.GetIsolate(), i), args[i]) .FromJust()"
); } } while (0)
;
126 }
127 args.GetReturnValue().Set(result);
128}
129
130
131static void Returns42(const v8::FunctionCallbackInfo<v8::Value>& info) {
132 info.GetReturnValue().Set(42);
133}
134
135
136// Tests that call v8::V8::Dispose() cannot be threaded.
137UNINITIALIZED_TEST(InitializeAndDisposeOnce)static void TestInitializeAndDisposeOnce(); CcTest register_test_InitializeAndDisposeOnce
(TestInitializeAndDisposeOnce, "../test/cctest/test-api.cc", "InitializeAndDisposeOnce"
, __null, true, false); static void TestInitializeAndDisposeOnce
()
{
138 CHECK(v8::V8::Initialize())do { if ((__builtin_expect(!!(!(v8::V8::Initialize())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 138, "Check failed: %s."
, "v8::V8::Initialize()"); } } while (0)
;
139 CHECK(v8::V8::Dispose())do { if ((__builtin_expect(!!(!(v8::V8::Dispose())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 139, "Check failed: %s.", "v8::V8::Dispose()"
); } } while (0)
;
140}
141
142
143// Tests that call v8::V8::Dispose() cannot be threaded.
144UNINITIALIZED_TEST(InitializeAndDisposeMultiple)static void TestInitializeAndDisposeMultiple(); CcTest register_test_InitializeAndDisposeMultiple
(TestInitializeAndDisposeMultiple, "../test/cctest/test-api.cc"
, "InitializeAndDisposeMultiple", __null, true, false); static
void TestInitializeAndDisposeMultiple()
{
145 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose())do { if ((__builtin_expect(!!(!(v8::V8::Dispose())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 145, "Check failed: %s.", "v8::V8::Dispose()"
); } } while (0)
;
146 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize())do { if ((__builtin_expect(!!(!(v8::V8::Initialize())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 146, "Check failed: %s."
, "v8::V8::Initialize()"); } } while (0)
;
147 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose())do { if ((__builtin_expect(!!(!(v8::V8::Dispose())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 147, "Check failed: %s.", "v8::V8::Dispose()"
); } } while (0)
;
148 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize())do { if ((__builtin_expect(!!(!(v8::V8::Initialize())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 148, "Check failed: %s."
, "v8::V8::Initialize()"); } } while (0)
;
149 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose())do { if ((__builtin_expect(!!(!(v8::V8::Dispose())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 149, "Check failed: %s.", "v8::V8::Dispose()"
); } } while (0)
;
150}
151
152
153THREADED_TEST(Handles)static void TestHandles(); RegisterThreadedTest register_Handles
(TestHandles, "Handles"); static void TestHandles(); CcTest register_test_Handles
(TestHandles, "../test/cctest/test-api.cc", "Handles", __null
, true, true); static void TestHandles()
{
154 v8::HandleScope scope(CcTest::isolate());
155 Local<Context> local_env;
156 {
157 LocalContext env;
158 local_env = env.local();
159 }
160
161 // Local context should still be live.
162 CHECK(!local_env.IsEmpty())do { if ((__builtin_expect(!!(!(!local_env.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 162, "Check failed: %s."
, "!local_env.IsEmpty()"); } } while (0)
;
163 local_env->Enter();
164
165 v8::Local<v8::Primitive> undef = v8::Undefined(CcTest::isolate());
166 CHECK(!undef.IsEmpty())do { if ((__builtin_expect(!!(!(!undef.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 166, "Check failed: %s.", "!undef.IsEmpty()"
); } } while (0)
;
167 CHECK(undef->IsUndefined())do { if ((__builtin_expect(!!(!(undef->IsUndefined())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 167, "Check failed: %s."
, "undef->IsUndefined()"); } } while (0)
;
168
169 const char* source = "1 + 2 + 3";
170 Local<Script> script = v8_compile(source);
171 CHECK_EQ(6, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (v8_run_int32value
(script)), "6" " " "==" " " "v8_run_int32value(script)")) { V8_Fatal
("../test/cctest/test-api.cc", 171, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
172
173 local_env->Exit();
174}
175
176
177THREADED_TEST(IsolateOfContext)static void TestIsolateOfContext(); RegisterThreadedTest register_IsolateOfContext
(TestIsolateOfContext, "IsolateOfContext"); static void TestIsolateOfContext
(); CcTest register_test_IsolateOfContext(TestIsolateOfContext
, "../test/cctest/test-api.cc", "IsolateOfContext", __null, true
, true); static void TestIsolateOfContext()
{
178 v8::HandleScope scope(CcTest::isolate());
179 v8::Local<Context> env = Context::New(CcTest::isolate());
180
181 CHECK(!env->GetIsolate()->InContext())do { if ((__builtin_expect(!!(!(!env->GetIsolate()->InContext
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 181, "Check failed: %s."
, "!env->GetIsolate()->InContext()"); } } while (0)
;
182 CHECK(env->GetIsolate() == CcTest::isolate())do { if ((__builtin_expect(!!(!(env->GetIsolate() == CcTest
::isolate())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 182
, "Check failed: %s.", "env->GetIsolate() == CcTest::isolate()"
); } } while (0)
;
183 env->Enter();
184 CHECK(env->GetIsolate()->InContext())do { if ((__builtin_expect(!!(!(env->GetIsolate()->InContext
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 184, "Check failed: %s."
, "env->GetIsolate()->InContext()"); } } while (0)
;
185 CHECK(env->GetIsolate() == CcTest::isolate())do { if ((__builtin_expect(!!(!(env->GetIsolate() == CcTest
::isolate())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 185
, "Check failed: %s.", "env->GetIsolate() == CcTest::isolate()"
); } } while (0)
;
186 env->Exit();
187 CHECK(!env->GetIsolate()->InContext())do { if ((__builtin_expect(!!(!(!env->GetIsolate()->InContext
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 187, "Check failed: %s."
, "!env->GetIsolate()->InContext()"); } } while (0)
;
188 CHECK(env->GetIsolate() == CcTest::isolate())do { if ((__builtin_expect(!!(!(env->GetIsolate() == CcTest
::isolate())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 188
, "Check failed: %s.", "env->GetIsolate() == CcTest::isolate()"
); } } while (0)
;
189}
190
191
192static void TestSignature(const char* loop_js, Local<Value> receiver,
193 v8::Isolate* isolate) {
194 i::ScopedVector<char> source(200);
195 i::SNPrintF(source,
196 "for (var i = 0; i < 10; i++) {"
197 " %s"
198 "}",
199 loop_js);
200 signature_callback_count = 0;
201 signature_expected_receiver = receiver;
202 bool expected_to_throw = receiver.IsEmpty();
203 v8::TryCatch try_catch(isolate);
204 CompileRun(source.start());
205 CHECK_EQ(expected_to_throw, try_catch.HasCaught())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected_to_throw
), (try_catch.HasCaught()), "expected_to_throw" " " "==" " " "try_catch.HasCaught()"
)) { V8_Fatal("../test/cctest/test-api.cc", 205, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
206 if (!expected_to_throw) {
207 CHECK_EQ(10, signature_callback_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10), (
signature_callback_count), "10" " " "==" " " "signature_callback_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 207, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
208 } else {
209 CHECK(v8_str("TypeError: Illegal invocation")do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals(isolate->GetCurrentContext(), try_catch.Exception
() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 214, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals(isolate->GetCurrentContext(), try_catch.Exception() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked()) .FromJust()"
); } } while (0)
210 ->Equals(isolate->GetCurrentContext(),do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals(isolate->GetCurrentContext(), try_catch.Exception
() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 214, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals(isolate->GetCurrentContext(), try_catch.Exception() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked()) .FromJust()"
); } } while (0)
211 try_catch.Exception()do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals(isolate->GetCurrentContext(), try_catch.Exception
() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 214, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals(isolate->GetCurrentContext(), try_catch.Exception() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked()) .FromJust()"
); } } while (0)
212 ->ToString(isolate->GetCurrentContext())do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals(isolate->GetCurrentContext(), try_catch.Exception
() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 214, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals(isolate->GetCurrentContext(), try_catch.Exception() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked()) .FromJust()"
); } } while (0)
213 .ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals(isolate->GetCurrentContext(), try_catch.Exception
() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 214, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals(isolate->GetCurrentContext(), try_catch.Exception() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked()) .FromJust()"
); } } while (0)
214 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals(isolate->GetCurrentContext(), try_catch.Exception
() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 214, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals(isolate->GetCurrentContext(), try_catch.Exception() ->ToString(isolate->GetCurrentContext()) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
215 }
216}
217
218
219THREADED_TEST(ReceiverSignature)static void TestReceiverSignature(); RegisterThreadedTest register_ReceiverSignature
(TestReceiverSignature, "ReceiverSignature"); static void TestReceiverSignature
(); CcTest register_test_ReceiverSignature(TestReceiverSignature
, "../test/cctest/test-api.cc", "ReceiverSignature", __null, true
, true); static void TestReceiverSignature()
{
220 LocalContext env;
221 v8::Isolate* isolate = env->GetIsolate();
222 v8::HandleScope scope(isolate);
223 // Setup templates.
224 v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate);
225 v8::Local<v8::Signature> sig = v8::Signature::New(isolate, fun);
226 v8::Local<v8::FunctionTemplate> callback_sig = v8::FunctionTemplate::New(
227 isolate, IncrementingSignatureCallback, Local<Value>(), sig);
228 v8::Local<v8::FunctionTemplate> callback =
229 v8::FunctionTemplate::New(isolate, IncrementingSignatureCallback);
230 v8::Local<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(isolate);
231 sub_fun->Inherit(fun);
232 v8::Local<v8::FunctionTemplate> unrel_fun =
233 v8::FunctionTemplate::New(isolate);
234 // Install properties.
235 v8::Local<v8::ObjectTemplate> fun_proto = fun->PrototypeTemplate();
236 fun_proto->Set(v8_str("prop_sig"), callback_sig);
237 fun_proto->Set(v8_str("prop"), callback);
238 fun_proto->SetAccessorProperty(
239 v8_str("accessor_sig"), callback_sig, callback_sig);
240 fun_proto->SetAccessorProperty(v8_str("accessor"), callback, callback);
241 // Instantiate templates.
242 Local<Value> fun_instance =
243 fun->InstanceTemplate()->NewInstance(env.local()).ToLocalChecked();
244 Local<Value> sub_fun_instance =
245 sub_fun->InstanceTemplate()->NewInstance(env.local()).ToLocalChecked();
246 // Setup global variables.
247 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Fun"), fun->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 250, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Fun\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
248 ->Set(env.local(), v8_str("Fun"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Fun"), fun->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 250, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Fun\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
249 fun->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Fun"), fun->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 250, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Fun\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
250 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Fun"), fun->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 250, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Fun\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
251 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("UnrelFun"), unrel_fun->GetFunction(env.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 254, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"UnrelFun\"), unrel_fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
252 ->Set(env.local(), v8_str("UnrelFun"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("UnrelFun"), unrel_fun->GetFunction(env.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 254, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"UnrelFun\"), unrel_fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
253 unrel_fun->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("UnrelFun"), unrel_fun->GetFunction(env.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 254, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"UnrelFun\"), unrel_fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
254 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("UnrelFun"), unrel_fun->GetFunction(env.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 254, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"UnrelFun\"), unrel_fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
255 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("fun_instance"), fun_instance) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 257, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"fun_instance\"), fun_instance) .FromJust()"
); } } while (0)
256 ->Set(env.local(), v8_str("fun_instance"), fun_instance)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("fun_instance"), fun_instance) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 257, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"fun_instance\"), fun_instance) .FromJust()"
); } } while (0)
257 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("fun_instance"), fun_instance) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 257, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"fun_instance\"), fun_instance) .FromJust()"
); } } while (0)
;
258 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("sub_fun_instance"), sub_fun_instance) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 260, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"sub_fun_instance\"), sub_fun_instance) .FromJust()"
); } } while (0)
259 ->Set(env.local(), v8_str("sub_fun_instance"), sub_fun_instance)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("sub_fun_instance"), sub_fun_instance) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 260, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"sub_fun_instance\"), sub_fun_instance) .FromJust()"
); } } while (0)
260 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("sub_fun_instance"), sub_fun_instance) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 260, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"sub_fun_instance\"), sub_fun_instance) .FromJust()"
); } } while (0)
;
261 CompileRun(
262 "var accessor_sig_key = 'accessor_sig';"
263 "var accessor_key = 'accessor';"
264 "var prop_sig_key = 'prop_sig';"
265 "var prop_key = 'prop';"
266 ""
267 "function copy_props(obj) {"
268 " var keys = [accessor_sig_key, accessor_key, prop_sig_key, prop_key];"
269 " var source = Fun.prototype;"
270 " for (var i in keys) {"
271 " var key = keys[i];"
272 " var desc = Object.getOwnPropertyDescriptor(source, key);"
273 " Object.defineProperty(obj, key, desc);"
274 " }"
275 "}"
276 ""
277 "var obj = {};"
278 "copy_props(obj);"
279 "var unrel = new UnrelFun();"
280 "copy_props(unrel);");
281 // Test with and without ICs
282 const char* test_objects[] = {
283 "fun_instance", "sub_fun_instance", "obj", "unrel" };
284 unsigned bad_signature_start_offset = 2;
285 for (unsigned i = 0; i < arraysize(test_objects)(sizeof(ArraySizeHelper(test_objects))); i++) {
286 i::ScopedVector<char> source(200);
287 i::SNPrintF(
288 source, "var test_object = %s; test_object", test_objects[i]);
289 Local<Value> test_object = CompileRun(source.start());
290 TestSignature("test_object.prop();", test_object, isolate);
291 TestSignature("test_object.accessor;", test_object, isolate);
292 TestSignature("test_object[accessor_key];", test_object, isolate);
293 TestSignature("test_object.accessor = 1;", test_object, isolate);
294 TestSignature("test_object[accessor_key] = 1;", test_object, isolate);
295 if (i >= bad_signature_start_offset) test_object = Local<Value>();
296 TestSignature("test_object.prop_sig();", test_object, isolate);
297 TestSignature("test_object.accessor_sig;", test_object, isolate);
298 TestSignature("test_object[accessor_sig_key];", test_object, isolate);
299 TestSignature("test_object.accessor_sig = 1;", test_object, isolate);
300 TestSignature("test_object[accessor_sig_key] = 1;", test_object, isolate);
301 }
302}
303
304
305THREADED_TEST(HulIgennem)static void TestHulIgennem(); RegisterThreadedTest register_HulIgennem
(TestHulIgennem, "HulIgennem"); static void TestHulIgennem();
CcTest register_test_HulIgennem(TestHulIgennem, "../test/cctest/test-api.cc"
, "HulIgennem", __null, true, true); static void TestHulIgennem
()
{
306 LocalContext env;
307 v8::Isolate* isolate = env->GetIsolate();
308 v8::HandleScope scope(isolate);
309 v8::Local<v8::Primitive> undef = v8::Undefined(isolate);
310 Local<String> undef_str = undef->ToString(env.local()).ToLocalChecked();
311 char* value = i::NewArray<char>(undef_str->Utf8Length() + 1);
312 undef_str->WriteUtf8(value);
313 CHECK_EQ(0, strcmp(value, "undefined"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(value, "undefined")), "0" " " "==" " " "strcmp(value, \"undefined\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 313, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
314 i::DeleteArray(value);
315}
316
317
318THREADED_TEST(Access)static void TestAccess(); RegisterThreadedTest register_Access
(TestAccess, "Access"); static void TestAccess(); CcTest register_test_Access
(TestAccess, "../test/cctest/test-api.cc", "Access", __null, true
, true); static void TestAccess()
{
319 LocalContext env;
320 v8::Isolate* isolate = env->GetIsolate();
321 v8::HandleScope scope(isolate);
322 Local<v8::Object> obj = v8::Object::New(isolate);
323 Local<Value> foo_before =
324 obj->Get(env.local(), v8_str("foo")).ToLocalChecked();
325 CHECK(foo_before->IsUndefined())do { if ((__builtin_expect(!!(!(foo_before->IsUndefined())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 325, "Check failed: %s."
, "foo_before->IsUndefined()"); } } while (0)
;
326 Local<String> bar_str = v8_str("bar");
327 CHECK(obj->Set(env.local(), v8_str("foo"), bar_str).FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8_str
("foo"), bar_str).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 327, "Check failed: %s.", "obj->Set(env.local(), v8_str(\"foo\"), bar_str).FromJust()"
); } } while (0)
;
328 Local<Value> foo_after =
329 obj->Get(env.local(), v8_str("foo")).ToLocalChecked();
330 CHECK(!foo_after->IsUndefined())do { if ((__builtin_expect(!!(!(!foo_after->IsUndefined())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 330, "Check failed: %s."
, "!foo_after->IsUndefined()"); } } while (0)
;
331 CHECK(foo_after->IsString())do { if ((__builtin_expect(!!(!(foo_after->IsString())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 331, "Check failed: %s."
, "foo_after->IsString()"); } } while (0)
;
332 CHECK(bar_str->Equals(env.local(), foo_after).FromJust())do { if ((__builtin_expect(!!(!(bar_str->Equals(env.local(
), foo_after).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 332, "Check failed: %s.", "bar_str->Equals(env.local(), foo_after).FromJust()"
); } } while (0)
;
333}
334
335
336THREADED_TEST(AccessElement)static void TestAccessElement(); RegisterThreadedTest register_AccessElement
(TestAccessElement, "AccessElement"); static void TestAccessElement
(); CcTest register_test_AccessElement(TestAccessElement, "../test/cctest/test-api.cc"
, "AccessElement", __null, true, true); static void TestAccessElement
()
{
337 LocalContext env;
338 v8::HandleScope scope(env->GetIsolate());
339 Local<v8::Object> obj = v8::Object::New(env->GetIsolate());
340 Local<Value> before = obj->Get(env.local(), 1).ToLocalChecked();
341 CHECK(before->IsUndefined())do { if ((__builtin_expect(!!(!(before->IsUndefined())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 341, "Check failed: %s."
, "before->IsUndefined()"); } } while (0)
;
342 Local<String> bar_str = v8_str("bar");
343 CHECK(obj->Set(env.local(), 1, bar_str).FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), 1, bar_str
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
343, "Check failed: %s.", "obj->Set(env.local(), 1, bar_str).FromJust()"
); } } while (0)
;
344 Local<Value> after = obj->Get(env.local(), 1).ToLocalChecked();
345 CHECK(!after->IsUndefined())do { if ((__builtin_expect(!!(!(!after->IsUndefined())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 345, "Check failed: %s."
, "!after->IsUndefined()"); } } while (0)
;
346 CHECK(after->IsString())do { if ((__builtin_expect(!!(!(after->IsString())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 346, "Check failed: %s."
, "after->IsString()"); } } while (0)
;
347 CHECK(bar_str->Equals(env.local(), after).FromJust())do { if ((__builtin_expect(!!(!(bar_str->Equals(env.local(
), after).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 347, "Check failed: %s.", "bar_str->Equals(env.local(), after).FromJust()"
); } } while (0)
;
348
349 Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>();
350 CHECK(v8_str("a")do { if ((__builtin_expect(!!(!(v8_str("a") ->Equals(env.local
(), value->Get(env.local(), 0).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 352, "Check failed: %s."
, "v8_str(\"a\") ->Equals(env.local(), value->Get(env.local(), 0).ToLocalChecked()) .FromJust()"
); } } while (0)
351 ->Equals(env.local(), value->Get(env.local(), 0).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("a") ->Equals(env.local
(), value->Get(env.local(), 0).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 352, "Check failed: %s."
, "v8_str(\"a\") ->Equals(env.local(), value->Get(env.local(), 0).ToLocalChecked()) .FromJust()"
); } } while (0)
352 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("a") ->Equals(env.local
(), value->Get(env.local(), 0).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 352, "Check failed: %s."
, "v8_str(\"a\") ->Equals(env.local(), value->Get(env.local(), 0).ToLocalChecked()) .FromJust()"
); } } while (0)
;
353 CHECK(v8_str("b")do { if ((__builtin_expect(!!(!(v8_str("b") ->Equals(env.local
(), value->Get(env.local(), 1).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 355, "Check failed: %s."
, "v8_str(\"b\") ->Equals(env.local(), value->Get(env.local(), 1).ToLocalChecked()) .FromJust()"
); } } while (0)
354 ->Equals(env.local(), value->Get(env.local(), 1).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("b") ->Equals(env.local
(), value->Get(env.local(), 1).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 355, "Check failed: %s."
, "v8_str(\"b\") ->Equals(env.local(), value->Get(env.local(), 1).ToLocalChecked()) .FromJust()"
); } } while (0)
355 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("b") ->Equals(env.local
(), value->Get(env.local(), 1).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 355, "Check failed: %s."
, "v8_str(\"b\") ->Equals(env.local(), value->Get(env.local(), 1).ToLocalChecked()) .FromJust()"
); } } while (0)
;
356}
357
358
359THREADED_TEST(Script)static void TestScript(); RegisterThreadedTest register_Script
(TestScript, "Script"); static void TestScript(); CcTest register_test_Script
(TestScript, "../test/cctest/test-api.cc", "Script", __null, true
, true); static void TestScript()
{
360 LocalContext env;
361 v8::HandleScope scope(env->GetIsolate());
362 const char* source = "1 + 2 + 3";
363 Local<Script> script = v8_compile(source);
364 CHECK_EQ(6, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (v8_run_int32value
(script)), "6" " " "==" " " "v8_run_int32value(script)")) { V8_Fatal
("../test/cctest/test-api.cc", 364, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
365}
366
367
368class TestResource: public String::ExternalStringResource {
369 public:
370 explicit TestResource(uint16_t* data, int* counter = NULL__null,
371 bool owning_data = true)
372 : data_(data), length_(0), counter_(counter), owning_data_(owning_data) {
373 while (data[length_]) ++length_;
374 }
375
376 ~TestResource() {
377 if (owning_data_) i::DeleteArray(data_);
378 if (counter_ != NULL__null) ++*counter_;
379 }
380
381 const uint16_t* data() const {
382 return data_;
383 }
384
385 size_t length() const {
386 return length_;
387 }
388
389 private:
390 uint16_t* data_;
391 size_t length_;
392 int* counter_;
393 bool owning_data_;
394};
395
396
397class TestOneByteResource : public String::ExternalOneByteStringResource {
398 public:
399 explicit TestOneByteResource(const char* data, int* counter = NULL__null,
400 size_t offset = 0)
401 : orig_data_(data),
402 data_(data + offset),
403 length_(strlen(data) - offset),
404 counter_(counter) {}
405
406 ~TestOneByteResource() {
407 i::DeleteArray(orig_data_);
408 if (counter_ != NULL__null) ++*counter_;
409 }
410
411 const char* data() const {
412 return data_;
413 }
414
415 size_t length() const {
416 return length_;
417 }
418
419 private:
420 const char* orig_data_;
421 const char* data_;
422 size_t length_;
423 int* counter_;
424};
425
426
427THREADED_TEST(ScriptUsingStringResource)static void TestScriptUsingStringResource(); RegisterThreadedTest
register_ScriptUsingStringResource(TestScriptUsingStringResource
, "ScriptUsingStringResource"); static void TestScriptUsingStringResource
(); CcTest register_test_ScriptUsingStringResource(TestScriptUsingStringResource
, "../test/cctest/test-api.cc", "ScriptUsingStringResource", __null
, true, true); static void TestScriptUsingStringResource()
{
428 int dispose_count = 0;
429 const char* c_source = "1 + 2 * 3";
430 uint16_t* two_byte_source = AsciiToTwoByteString(c_source);
431 {
432 LocalContext env;
433 v8::HandleScope scope(env->GetIsolate());
434 TestResource* resource = new TestResource(two_byte_source, &dispose_count);
435 Local<String> source =
436 String::NewExternalTwoByte(env->GetIsolate(), resource)
437 .ToLocalChecked();
438 Local<Script> script = v8_compile(source);
439 Local<Value> value = script->Run(env.local()).ToLocalChecked();
440 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 440, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
441 CHECK_EQ(7, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (value
->Int32Value(env.local()).FromJust()), "7" " " "==" " " "value->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 441, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
442 CHECK(source->IsExternal())do { if ((__builtin_expect(!!(!(source->IsExternal())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 442, "Check failed: %s."
, "source->IsExternal()"); } } while (0)
;
443 CHECK_EQ(resource,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (resource
), (static_cast<TestResource*>(source->GetExternalStringResource
())), "resource" " " "==" " " "static_cast<TestResource*>(source->GetExternalStringResource())"
)) { V8_Fatal("../test/cctest/test-api.cc", 444, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
444 static_cast<TestResource*>(source->GetExternalStringResource()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (resource
), (static_cast<TestResource*>(source->GetExternalStringResource
())), "resource" " " "==" " " "static_cast<TestResource*>(source->GetExternalStringResource())"
)) { V8_Fatal("../test/cctest/test-api.cc", 444, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
445 String::Encoding encoding = String::UNKNOWN_ENCODING;
446 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<const String::ExternalStringResourceBase*>(resource)),
(source->GetExternalStringResourceBase(&encoding)), "static_cast<const String::ExternalStringResourceBase*>(resource)"
" " "==" " " "source->GetExternalStringResourceBase(&encoding)"
)) { V8_Fatal("../test/cctest/test-api.cc", 447, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
447 source->GetExternalStringResourceBase(&encoding))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<const String::ExternalStringResourceBase*>(resource)),
(source->GetExternalStringResourceBase(&encoding)), "static_cast<const String::ExternalStringResourceBase*>(resource)"
" " "==" " " "source->GetExternalStringResourceBase(&encoding)"
)) { V8_Fatal("../test/cctest/test-api.cc", 447, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
448 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (String
::TWO_BYTE_ENCODING), (encoding), "String::TWO_BYTE_ENCODING"
" " "==" " " "encoding")) { V8_Fatal("../test/cctest/test-api.cc"
, 448, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
449 CcTest::heap()->CollectAllGarbage();
450 CHECK_EQ(0, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (dispose_count
), "0" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 450, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
451 }
452 CcTest::i_isolate()->compilation_cache()->Clear();
453 CcTest::heap()->CollectAllAvailableGarbage();
454 CHECK_EQ(1, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (dispose_count
), "1" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 454, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
455}
456
457
458THREADED_TEST(ScriptUsingOneByteStringResource)static void TestScriptUsingOneByteStringResource(); RegisterThreadedTest
register_ScriptUsingOneByteStringResource(TestScriptUsingOneByteStringResource
, "ScriptUsingOneByteStringResource"); static void TestScriptUsingOneByteStringResource
(); CcTest register_test_ScriptUsingOneByteStringResource(TestScriptUsingOneByteStringResource
, "../test/cctest/test-api.cc", "ScriptUsingOneByteStringResource"
, __null, true, true); static void TestScriptUsingOneByteStringResource
()
{
459 int dispose_count = 0;
460 const char* c_source = "1 + 2 * 3";
461 {
462 LocalContext env;
463 v8::HandleScope scope(env->GetIsolate());
464 TestOneByteResource* resource =
465 new TestOneByteResource(i::StrDup(c_source), &dispose_count);
466 Local<String> source =
467 String::NewExternalOneByte(env->GetIsolate(), resource)
468 .ToLocalChecked();
469 CHECK(source->IsExternalOneByte())do { if ((__builtin_expect(!!(!(source->IsExternalOneByte(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 469, "Check failed: %s."
, "source->IsExternalOneByte()"); } } while (0)
;
470 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<const String::ExternalStringResourceBase*>(resource)),
(source->GetExternalOneByteStringResource()), "static_cast<const String::ExternalStringResourceBase*>(resource)"
" " "==" " " "source->GetExternalOneByteStringResource()"
)) { V8_Fatal("../test/cctest/test-api.cc", 471, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
471 source->GetExternalOneByteStringResource())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<const String::ExternalStringResourceBase*>(resource)),
(source->GetExternalOneByteStringResource()), "static_cast<const String::ExternalStringResourceBase*>(resource)"
" " "==" " " "source->GetExternalOneByteStringResource()"
)) { V8_Fatal("../test/cctest/test-api.cc", 471, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
472 String::Encoding encoding = String::UNKNOWN_ENCODING;
473 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<const String::ExternalStringResourceBase*>(resource)),
(source->GetExternalStringResourceBase(&encoding)), "static_cast<const String::ExternalStringResourceBase*>(resource)"
" " "==" " " "source->GetExternalStringResourceBase(&encoding)"
)) { V8_Fatal("../test/cctest/test-api.cc", 474, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
474 source->GetExternalStringResourceBase(&encoding))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<const String::ExternalStringResourceBase*>(resource)),
(source->GetExternalStringResourceBase(&encoding)), "static_cast<const String::ExternalStringResourceBase*>(resource)"
" " "==" " " "source->GetExternalStringResourceBase(&encoding)"
)) { V8_Fatal("../test/cctest/test-api.cc", 474, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
475 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (String
::ONE_BYTE_ENCODING), (encoding), "String::ONE_BYTE_ENCODING"
" " "==" " " "encoding")) { V8_Fatal("../test/cctest/test-api.cc"
, 475, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
476 Local<Script> script = v8_compile(source);
477 Local<Value> value = script->Run(env.local()).ToLocalChecked();
478 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 478, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
479 CHECK_EQ(7, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (value
->Int32Value(env.local()).FromJust()), "7" " " "==" " " "value->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 479, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
480 CcTest::heap()->CollectAllGarbage();
481 CHECK_EQ(0, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (dispose_count
), "0" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 481, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
482 }
483 CcTest::i_isolate()->compilation_cache()->Clear();
484 CcTest::heap()->CollectAllAvailableGarbage();
485 CHECK_EQ(1, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (dispose_count
), "1" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 485, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
486}
487
488
489THREADED_TEST(ScriptMakingExternalString)static void TestScriptMakingExternalString(); RegisterThreadedTest
register_ScriptMakingExternalString(TestScriptMakingExternalString
, "ScriptMakingExternalString"); static void TestScriptMakingExternalString
(); CcTest register_test_ScriptMakingExternalString(TestScriptMakingExternalString
, "../test/cctest/test-api.cc", "ScriptMakingExternalString",
__null, true, true); static void TestScriptMakingExternalString
()
{
490 int dispose_count = 0;
491 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3");
492 {
493 LocalContext env;
494 v8::HandleScope scope(env->GetIsolate());
495 Local<String> source =
496 String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
497 v8::NewStringType::kNormal)
498 .ToLocalChecked();
499 // Trigger GCs so that the newly allocated string moves to old gen.
500 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
501 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
502 CHECK_EQ(source->IsExternal(), false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (source
->IsExternal()), (false), "source->IsExternal()" " " "=="
" " "false")) { V8_Fatal("../test/cctest/test-api.cc", 502, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
503 CHECK_EQ(source->IsExternalOneByte(), false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (source
->IsExternalOneByte()), (false), "source->IsExternalOneByte()"
" " "==" " " "false")) { V8_Fatal("../test/cctest/test-api.cc"
, 503, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
504 String::Encoding encoding = String::UNKNOWN_ENCODING;
505 CHECK(!source->GetExternalStringResourceBase(&encoding))do { if ((__builtin_expect(!!(!(!source->GetExternalStringResourceBase
(&encoding))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 505, "Check failed: %s.", "!source->GetExternalStringResourceBase(&encoding)"
); } } while (0)
;
506 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (String
::ONE_BYTE_ENCODING), (encoding), "String::ONE_BYTE_ENCODING"
" " "==" " " "encoding")) { V8_Fatal("../test/cctest/test-api.cc"
, 506, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
507 bool success = source->MakeExternal(new TestResource(two_byte_source,
508 &dispose_count));
509 CHECK(success)do { if ((__builtin_expect(!!(!(success)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 509, "Check failed: %s.", "success"); } } while (0)
;
510 Local<Script> script = v8_compile(source);
511 Local<Value> value = script->Run(env.local()).ToLocalChecked();
512 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 512, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
513 CHECK_EQ(7, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (value
->Int32Value(env.local()).FromJust()), "7" " " "==" " " "value->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 513, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
514 CcTest::heap()->CollectAllGarbage();
515 CHECK_EQ(0, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (dispose_count
), "0" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 515, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
516 }
517 CcTest::i_isolate()->compilation_cache()->Clear();
518 CcTest::heap()->CollectAllGarbage();
519 CHECK_EQ(1, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (dispose_count
), "1" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 519, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
520}
521
522
523THREADED_TEST(ScriptMakingExternalOneByteString)static void TestScriptMakingExternalOneByteString(); RegisterThreadedTest
register_ScriptMakingExternalOneByteString(TestScriptMakingExternalOneByteString
, "ScriptMakingExternalOneByteString"); static void TestScriptMakingExternalOneByteString
(); CcTest register_test_ScriptMakingExternalOneByteString(TestScriptMakingExternalOneByteString
, "../test/cctest/test-api.cc", "ScriptMakingExternalOneByteString"
, __null, true, true); static void TestScriptMakingExternalOneByteString
()
{
524 int dispose_count = 0;
525 const char* c_source = "1 + 2 * 3";
526 {
527 LocalContext env;
528 v8::HandleScope scope(env->GetIsolate());
529 Local<String> source = v8_str(c_source);
530 // Trigger GCs so that the newly allocated string moves to old gen.
531 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
532 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
533 bool success = source->MakeExternal(
534 new TestOneByteResource(i::StrDup(c_source), &dispose_count));
535 CHECK(success)do { if ((__builtin_expect(!!(!(success)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 535, "Check failed: %s.", "success"); } } while (0)
;
536 Local<Script> script = v8_compile(source);
537 Local<Value> value = script->Run(env.local()).ToLocalChecked();
538 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 538, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
539 CHECK_EQ(7, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (value
->Int32Value(env.local()).FromJust()), "7" " " "==" " " "value->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 539, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
540 CcTest::heap()->CollectAllGarbage();
541 CHECK_EQ(0, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (dispose_count
), "0" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 541, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
542 }
543 CcTest::i_isolate()->compilation_cache()->Clear();
544 CcTest::heap()->CollectAllGarbage();
545 CHECK_EQ(1, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (dispose_count
), "1" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 545, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
546}
547
548
549TEST(MakingExternalStringConditions)static void TestMakingExternalStringConditions(); CcTest register_test_MakingExternalStringConditions
(TestMakingExternalStringConditions, "../test/cctest/test-api.cc"
, "MakingExternalStringConditions", __null, true, true); static
void TestMakingExternalStringConditions()
{
550 LocalContext env;
551 v8::HandleScope scope(env->GetIsolate());
552
553 // Free some space in the new space so that we can check freshness.
554 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
555 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
556
557 uint16_t* two_byte_string = AsciiToTwoByteString("s1");
558 Local<String> small_string =
559 String::NewFromTwoByte(env->GetIsolate(), two_byte_string,
560 v8::NewStringType::kNormal)
561 .ToLocalChecked();
562 i::DeleteArray(two_byte_string);
563
564 // We should refuse to externalize small strings.
565 CHECK(!small_string->CanMakeExternal())do { if ((__builtin_expect(!!(!(!small_string->CanMakeExternal
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 565, "Check failed: %s."
, "!small_string->CanMakeExternal()"); } } while (0)
;
566 // Trigger GCs so that the newly allocated string moves to old gen.
567 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
568 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
569 // Old space strings should be accepted.
570 CHECK(small_string->CanMakeExternal())do { if ((__builtin_expect(!!(!(small_string->CanMakeExternal
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 570, "Check failed: %s."
, "small_string->CanMakeExternal()"); } } while (0)
;
571
572 two_byte_string = AsciiToTwoByteString("small string 2");
573 small_string = String::NewFromTwoByte(env->GetIsolate(), two_byte_string,
574 v8::NewStringType::kNormal)
575 .ToLocalChecked();
576 i::DeleteArray(two_byte_string);
577
578 const int buf_size = 10 * 1024;
579 char* buf = i::NewArray<char>(buf_size);
580 memset(buf, 'a', buf_size);
581 buf[buf_size - 1] = '\0';
582
583 two_byte_string = AsciiToTwoByteString(buf);
584 Local<String> large_string =
585 String::NewFromTwoByte(env->GetIsolate(), two_byte_string,
586 v8::NewStringType::kNormal)
587 .ToLocalChecked();
588 i::DeleteArray(buf);
589 i::DeleteArray(two_byte_string);
590 // Large strings should be immediately accepted.
591 CHECK(large_string->CanMakeExternal())do { if ((__builtin_expect(!!(!(large_string->CanMakeExternal
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 591, "Check failed: %s."
, "large_string->CanMakeExternal()"); } } while (0)
;
592}
593
594
595TEST(MakingExternalOneByteStringConditions)static void TestMakingExternalOneByteStringConditions(); CcTest
register_test_MakingExternalOneByteStringConditions(TestMakingExternalOneByteStringConditions
, "../test/cctest/test-api.cc", "MakingExternalOneByteStringConditions"
, __null, true, true); static void TestMakingExternalOneByteStringConditions
()
{
596 LocalContext env;
597 v8::HandleScope scope(env->GetIsolate());
598
599 // Free some space in the new space so that we can check freshness.
600 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
601 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
602
603 Local<String> small_string = v8_str("s1");
604 // We should refuse to externalize small strings.
605 CHECK(!small_string->CanMakeExternal())do { if ((__builtin_expect(!!(!(!small_string->CanMakeExternal
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 605, "Check failed: %s."
, "!small_string->CanMakeExternal()"); } } while (0)
;
606 // Trigger GCs so that the newly allocated string moves to old gen.
607 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
608 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
609 // Old space strings should be accepted.
610 CHECK(small_string->CanMakeExternal())do { if ((__builtin_expect(!!(!(small_string->CanMakeExternal
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 610, "Check failed: %s."
, "small_string->CanMakeExternal()"); } } while (0)
;
611
612 const int buf_size = 10 * 1024;
613 char* buf = i::NewArray<char>(buf_size);
614 memset(buf, 'a', buf_size);
615 buf[buf_size - 1] = '\0';
616 Local<String> large_string = v8_str(buf);
617 i::DeleteArray(buf);
618 // Large strings should be immediately accepted.
619 CHECK(large_string->CanMakeExternal())do { if ((__builtin_expect(!!(!(large_string->CanMakeExternal
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 619, "Check failed: %s."
, "large_string->CanMakeExternal()"); } } while (0)
;
620}
621
622
623TEST(MakingExternalUnalignedOneByteString)static void TestMakingExternalUnalignedOneByteString(); CcTest
register_test_MakingExternalUnalignedOneByteString(TestMakingExternalUnalignedOneByteString
, "../test/cctest/test-api.cc", "MakingExternalUnalignedOneByteString"
, __null, true, true); static void TestMakingExternalUnalignedOneByteString
()
{
624 LocalContext env;
625 v8::HandleScope scope(env->GetIsolate());
626
627 CompileRun("function cons(a, b) { return a + b; }"
628 "function slice(a) { return a.substring(1); }");
629 // Create a cons string that will land in old pointer space.
630 Local<String> cons = Local<String>::Cast(CompileRun(
631 "cons('abcdefghijklm', 'nopqrstuvwxyz');"));
632 // Create a sliced string that will land in old pointer space.
633 Local<String> slice = Local<String>::Cast(CompileRun(
634 "slice('abcdefghijklmnopqrstuvwxyz');"));
635
636 // Trigger GCs so that the newly allocated string moves to old gen.
637 SimulateFullSpace(CcTest::heap()->old_space());
638 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
639 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
640
641 // Turn into external string with unaligned resource data.
642 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz";
643 bool success =
644 cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL__null, 1));
645 CHECK(success)do { if ((__builtin_expect(!!(!(success)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 645, "Check failed: %s.", "success"); } } while (0)
;
646 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz";
647 success =
648 slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL__null, 1));
649 CHECK(success)do { if ((__builtin_expect(!!(!(success)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 649, "Check failed: %s.", "success"); } } while (0)
;
650
651 // Trigger GCs and force evacuation.
652 CcTest::heap()->CollectAllGarbage();
653 CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask);
654}
655
656
657THREADED_TEST(UsingExternalString)static void TestUsingExternalString(); RegisterThreadedTest register_UsingExternalString
(TestUsingExternalString, "UsingExternalString"); static void
TestUsingExternalString(); CcTest register_test_UsingExternalString
(TestUsingExternalString, "../test/cctest/test-api.cc", "UsingExternalString"
, __null, true, true); static void TestUsingExternalString()
{
658 i::Factory* factory = CcTest::i_isolate()->factory();
659 {
660 v8::HandleScope scope(CcTest::isolate());
661 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
662 Local<String> string =
663 String::NewExternalTwoByte(CcTest::isolate(),
664 new TestResource(two_byte_string))
665 .ToLocalChecked();
666 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
667 // Trigger GCs so that the newly allocated string moves to old gen.
668 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
669 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
670 i::Handle<i::String> isymbol =
671 factory->InternalizeString(istring);
672 CHECK(isymbol->IsInternalizedString())do { if ((__builtin_expect(!!(!(isymbol->IsInternalizedString
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 672, "Check failed: %s."
, "isymbol->IsInternalizedString()"); } } while (0)
;
673 }
674 CcTest::heap()->CollectAllGarbage();
675 CcTest::heap()->CollectAllGarbage();
676}
677
678
679THREADED_TEST(UsingExternalOneByteString)static void TestUsingExternalOneByteString(); RegisterThreadedTest
register_UsingExternalOneByteString(TestUsingExternalOneByteString
, "UsingExternalOneByteString"); static void TestUsingExternalOneByteString
(); CcTest register_test_UsingExternalOneByteString(TestUsingExternalOneByteString
, "../test/cctest/test-api.cc", "UsingExternalOneByteString",
__null, true, true); static void TestUsingExternalOneByteString
()
{
680 i::Factory* factory = CcTest::i_isolate()->factory();
681 {
682 v8::HandleScope scope(CcTest::isolate());
683 const char* one_byte_string = "test string";
684 Local<String> string =
685 String::NewExternalOneByte(
686 CcTest::isolate(),
687 new TestOneByteResource(i::StrDup(one_byte_string)))
688 .ToLocalChecked();
689 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
690 // Trigger GCs so that the newly allocated string moves to old gen.
691 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
692 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
693 i::Handle<i::String> isymbol =
694 factory->InternalizeString(istring);
695 CHECK(isymbol->IsInternalizedString())do { if ((__builtin_expect(!!(!(isymbol->IsInternalizedString
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 695, "Check failed: %s."
, "isymbol->IsInternalizedString()"); } } while (0)
;
696 }
697 CcTest::heap()->CollectAllGarbage();
698 CcTest::heap()->CollectAllGarbage();
699}
700
701
702class RandomLengthResource : public v8::String::ExternalStringResource {
703 public:
704 explicit RandomLengthResource(int length) : length_(length) {}
705 virtual const uint16_t* data() const { return string_; }
706 virtual size_t length() const { return length_; }
707
708 private:
709 uint16_t string_[10];
710 int length_;
711};
712
713
714class RandomLengthOneByteResource
715 : public v8::String::ExternalOneByteStringResource {
716 public:
717 explicit RandomLengthOneByteResource(int length) : length_(length) {}
718 virtual const char* data() const { return string_; }
719 virtual size_t length() const { return length_; }
720
721 private:
722 char string_[10];
723 int length_;
724};
725
726
727THREADED_TEST(NewExternalForVeryLongString)static void TestNewExternalForVeryLongString(); RegisterThreadedTest
register_NewExternalForVeryLongString(TestNewExternalForVeryLongString
, "NewExternalForVeryLongString"); static void TestNewExternalForVeryLongString
(); CcTest register_test_NewExternalForVeryLongString(TestNewExternalForVeryLongString
, "../test/cctest/test-api.cc", "NewExternalForVeryLongString"
, __null, true, true); static void TestNewExternalForVeryLongString
()
{
728 auto isolate = CcTest::isolate();
729 {
730 v8::HandleScope scope(isolate);
731 v8::TryCatch try_catch(isolate);
732 RandomLengthOneByteResource r(1 << 30);
733 v8::MaybeLocal<v8::String> maybe_str =
734 v8::String::NewExternalOneByte(isolate, &r);
735 CHECK(maybe_str.IsEmpty())do { if ((__builtin_expect(!!(!(maybe_str.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 735, "Check failed: %s."
, "maybe_str.IsEmpty()"); } } while (0)
;
736 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 736, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
737 }
738
739 {
740 v8::HandleScope scope(isolate);
741 v8::TryCatch try_catch(isolate);
742 RandomLengthResource r(1 << 30);
743 v8::MaybeLocal<v8::String> maybe_str =
744 v8::String::NewExternalTwoByte(isolate, &r);
745 CHECK(maybe_str.IsEmpty())do { if ((__builtin_expect(!!(!(maybe_str.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 745, "Check failed: %s."
, "maybe_str.IsEmpty()"); } } while (0)
;
746 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 746, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
747 }
748}
749
750
751THREADED_TEST(ScavengeExternalString)static void TestScavengeExternalString(); RegisterThreadedTest
register_ScavengeExternalString(TestScavengeExternalString, "ScavengeExternalString"
); static void TestScavengeExternalString(); CcTest register_test_ScavengeExternalString
(TestScavengeExternalString, "../test/cctest/test-api.cc", "ScavengeExternalString"
, __null, true, true); static void TestScavengeExternalString
()
{
752 i::FLAG_stress_compaction = false;
753 i::FLAG_gc_global = false;
754 int dispose_count = 0;
755 bool in_new_space = false;
756 {
757 v8::HandleScope scope(CcTest::isolate());
758 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
759 Local<String> string =
760 String::NewExternalTwoByte(
761 CcTest::isolate(),
762 new TestResource(two_byte_string, &dispose_count))
763 .ToLocalChecked();
764 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
765 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
766 in_new_space = CcTest::heap()->InNewSpace(*istring);
767 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring))do { if ((__builtin_expect(!!(!(in_new_space || CcTest::heap(
)->old_space()->Contains(*istring))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 767, "Check failed: %s.", "in_new_space || CcTest::heap()->old_space()->Contains(*istring)"
); } } while (0)
;
768 CHECK_EQ(0, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (dispose_count
), "0" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 768, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
769 }
770 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE);
771 CHECK_EQ(1, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (dispose_count
), "1" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 771, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
772}
773
774
775THREADED_TEST(ScavengeExternalOneByteString)static void TestScavengeExternalOneByteString(); RegisterThreadedTest
register_ScavengeExternalOneByteString(TestScavengeExternalOneByteString
, "ScavengeExternalOneByteString"); static void TestScavengeExternalOneByteString
(); CcTest register_test_ScavengeExternalOneByteString(TestScavengeExternalOneByteString
, "../test/cctest/test-api.cc", "ScavengeExternalOneByteString"
, __null, true, true); static void TestScavengeExternalOneByteString
()
{
776 i::FLAG_stress_compaction = false;
777 i::FLAG_gc_global = false;
778 int dispose_count = 0;
779 bool in_new_space = false;
780 {
781 v8::HandleScope scope(CcTest::isolate());
782 const char* one_byte_string = "test string";
783 Local<String> string =
784 String::NewExternalOneByte(
785 CcTest::isolate(),
786 new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count))
787 .ToLocalChecked();
788 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
789 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
790 in_new_space = CcTest::heap()->InNewSpace(*istring);
791 CHECK(in_new_space || CcTest::heap()->old_space()->Contains(*istring))do { if ((__builtin_expect(!!(!(in_new_space || CcTest::heap(
)->old_space()->Contains(*istring))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 791, "Check failed: %s.", "in_new_space || CcTest::heap()->old_space()->Contains(*istring)"
); } } while (0)
;
792 CHECK_EQ(0, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (dispose_count
), "0" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 792, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
793 }
794 CcTest::heap()->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_SPACE);
795 CHECK_EQ(1, dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (dispose_count
), "1" " " "==" " " "dispose_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 795, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
796}
797
798
799class TestOneByteResourceWithDisposeControl : public TestOneByteResource {
800 public:
801 // Only used by non-threaded tests, so it can use static fields.
802 static int dispose_calls;
803 static int dispose_count;
804
805 TestOneByteResourceWithDisposeControl(const char* data, bool dispose)
806 : TestOneByteResource(data, &dispose_count), dispose_(dispose) {}
807
808 void Dispose() {
809 ++dispose_calls;
810 if (dispose_) delete this;
811 }
812 private:
813 bool dispose_;
814};
815
816
817int TestOneByteResourceWithDisposeControl::dispose_count = 0;
818int TestOneByteResourceWithDisposeControl::dispose_calls = 0;
819
820
821TEST(ExternalStringWithDisposeHandling)static void TestExternalStringWithDisposeHandling(); CcTest register_test_ExternalStringWithDisposeHandling
(TestExternalStringWithDisposeHandling, "../test/cctest/test-api.cc"
, "ExternalStringWithDisposeHandling", __null, true, true); static
void TestExternalStringWithDisposeHandling()
{
822 const char* c_source = "1 + 2 * 3";
823
824 // Use a stack allocated external string resource allocated object.
825 TestOneByteResourceWithDisposeControl::dispose_count = 0;
826 TestOneByteResourceWithDisposeControl::dispose_calls = 0;
827 TestOneByteResourceWithDisposeControl res_stack(i::StrDup(c_source), false);
828 {
829 LocalContext env;
830 v8::HandleScope scope(env->GetIsolate());
831 Local<String> source =
832 String::NewExternalOneByte(env->GetIsolate(), &res_stack)
833 .ToLocalChecked();
834 Local<Script> script = v8_compile(source);
835 Local<Value> value = script->Run(env.local()).ToLocalChecked();
836 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 836, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
837 CHECK_EQ(7, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (value
->Int32Value(env.local()).FromJust()), "7" " " "==" " " "value->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 837, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
838 CcTest::heap()->CollectAllAvailableGarbage();
839 CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (TestOneByteResourceWithDisposeControl
::dispose_count), "0" " " "==" " " "TestOneByteResourceWithDisposeControl::dispose_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 839, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
840 }
841 CcTest::i_isolate()->compilation_cache()->Clear();
842 CcTest::heap()->CollectAllAvailableGarbage();
843 CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_calls)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (TestOneByteResourceWithDisposeControl
::dispose_calls), "1" " " "==" " " "TestOneByteResourceWithDisposeControl::dispose_calls"
)) { V8_Fatal("../test/cctest/test-api.cc", 843, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
844 CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (TestOneByteResourceWithDisposeControl
::dispose_count), "0" " " "==" " " "TestOneByteResourceWithDisposeControl::dispose_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 844, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
845
846 // Use a heap allocated external string resource allocated object.
847 TestOneByteResourceWithDisposeControl::dispose_count = 0;
848 TestOneByteResourceWithDisposeControl::dispose_calls = 0;
849 TestOneByteResource* res_heap =
850 new TestOneByteResourceWithDisposeControl(i::StrDup(c_source), true);
851 {
852 LocalContext env;
853 v8::HandleScope scope(env->GetIsolate());
854 Local<String> source =
855 String::NewExternalOneByte(env->GetIsolate(), res_heap)
856 .ToLocalChecked();
857 Local<Script> script = v8_compile(source);
858 Local<Value> value = script->Run(env.local()).ToLocalChecked();
859 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 859, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
860 CHECK_EQ(7, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (value
->Int32Value(env.local()).FromJust()), "7" " " "==" " " "value->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 860, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
861 CcTest::heap()->CollectAllAvailableGarbage();
862 CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (TestOneByteResourceWithDisposeControl
::dispose_count), "0" " " "==" " " "TestOneByteResourceWithDisposeControl::dispose_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 862, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
863 }
864 CcTest::i_isolate()->compilation_cache()->Clear();
865 CcTest::heap()->CollectAllAvailableGarbage();
866 CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_calls)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (TestOneByteResourceWithDisposeControl
::dispose_calls), "1" " " "==" " " "TestOneByteResourceWithDisposeControl::dispose_calls"
)) { V8_Fatal("../test/cctest/test-api.cc", 866, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
867 CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (TestOneByteResourceWithDisposeControl
::dispose_count), "1" " " "==" " " "TestOneByteResourceWithDisposeControl::dispose_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 867, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
868}
869
870
871THREADED_TEST(StringConcat)static void TestStringConcat(); RegisterThreadedTest register_StringConcat
(TestStringConcat, "StringConcat"); static void TestStringConcat
(); CcTest register_test_StringConcat(TestStringConcat, "../test/cctest/test-api.cc"
, "StringConcat", __null, true, true); static void TestStringConcat
()
{
872 {
873 LocalContext env;
874 v8::HandleScope scope(env->GetIsolate());
875 const char* one_byte_string_1 = "function a_times_t";
876 const char* two_byte_string_1 = "wo_plus_b(a, b) {return ";
877 const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + ";
878 const char* two_byte_extern_1 = "a_times_two_plus_b(4, 8) + ";
879 const char* one_byte_string_2 = "a_times_two_plus_b(4, 8) + ";
880 const char* two_byte_string_2 = "a_times_two_plus_b(4, 8) + ";
881 const char* two_byte_extern_2 = "a_times_two_plus_b(1, 2);";
882 Local<String> left = v8_str(one_byte_string_1);
883
884 uint16_t* two_byte_source = AsciiToTwoByteString(two_byte_string_1);
885 Local<String> right =
886 String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
887 v8::NewStringType::kNormal)
888 .ToLocalChecked();
889 i::DeleteArray(two_byte_source);
890
891 Local<String> source = String::Concat(left, right);
892 right = String::NewExternalOneByte(
893 env->GetIsolate(),
894 new TestOneByteResource(i::StrDup(one_byte_extern_1)))
895 .ToLocalChecked();
896 source = String::Concat(source, right);
897 right = String::NewExternalTwoByte(
898 env->GetIsolate(),
899 new TestResource(AsciiToTwoByteString(two_byte_extern_1)))
900 .ToLocalChecked();
901 source = String::Concat(source, right);
902 right = v8_str(one_byte_string_2);
903 source = String::Concat(source, right);
904
905 two_byte_source = AsciiToTwoByteString(two_byte_string_2);
906 right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source,
907 v8::NewStringType::kNormal)
908 .ToLocalChecked();
909 i::DeleteArray(two_byte_source);
910
911 source = String::Concat(source, right);
912 right = String::NewExternalTwoByte(
913 env->GetIsolate(),
914 new TestResource(AsciiToTwoByteString(two_byte_extern_2)))
915 .ToLocalChecked();
916 source = String::Concat(source, right);
917 Local<Script> script = v8_compile(source);
918 Local<Value> value = script->Run(env.local()).ToLocalChecked();
919 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 919, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
920 CHECK_EQ(68, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (68), (
value->Int32Value(env.local()).FromJust()), "68" " " "==" " "
"value->Int32Value(env.local()).FromJust()")) { V8_Fatal(
"../test/cctest/test-api.cc", 920, "Check failed: %s.", _msg->
c_str()); delete _msg; } } while (0)
;
921 }
922 CcTest::i_isolate()->compilation_cache()->Clear();
923 CcTest::heap()->CollectAllGarbage();
924 CcTest::heap()->CollectAllGarbage();
925}
926
927
928THREADED_TEST(GlobalProperties)static void TestGlobalProperties(); RegisterThreadedTest register_GlobalProperties
(TestGlobalProperties, "GlobalProperties"); static void TestGlobalProperties
(); CcTest register_test_GlobalProperties(TestGlobalProperties
, "../test/cctest/test-api.cc", "GlobalProperties", __null, true
, true); static void TestGlobalProperties()
{
929 LocalContext env;
930 v8::HandleScope scope(env->GetIsolate());
931 v8::Local<v8::Object> global = env->Global();
932 CHECK(global->Set(env.local(), v8_str("pi"), v8_num(3.1415926)).FromJust())do { if ((__builtin_expect(!!(!(global->Set(env.local(), v8_str
("pi"), v8_num(3.1415926)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 932, "Check failed: %s.", "global->Set(env.local(), v8_str(\"pi\"), v8_num(3.1415926)).FromJust()"
); } } while (0)
;
933 Local<Value> pi = global->Get(env.local(), v8_str("pi")).ToLocalChecked();
934 CHECK_EQ(3.1415926, pi->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.1415926
), (pi->NumberValue(env.local()).FromJust()), "3.1415926" " "
"==" " " "pi->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 934, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
935}
936
937
938static void handle_callback_impl(const v8::FunctionCallbackInfo<Value>& info,
939 i::Address callback) {
940 ApiTestFuzzer::Fuzz();
941 CheckReturnValue(info, callback);
942 info.GetReturnValue().Set(v8_str("bad value"));
943 info.GetReturnValue().Set(v8_num(102));
944}
945
946
947static void handle_callback(const v8::FunctionCallbackInfo<Value>& info) {
948 return handle_callback_impl(info, FUNCTION_ADDR(handle_callback)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(handle_callback)))
);
949}
950
951
952static void handle_callback_2(const v8::FunctionCallbackInfo<Value>& info) {
953 return handle_callback_impl(info, FUNCTION_ADDR(handle_callback_2)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(handle_callback_2)))
);
954}
955
956static void construct_callback(
957 const v8::FunctionCallbackInfo<Value>& info) {
958 ApiTestFuzzer::Fuzz();
959 CheckReturnValue(info, FUNCTION_ADDR(construct_callback)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(construct_callback)))
);
960 CHECK(do { if ((__builtin_expect(!!(!(info.This() ->Set(info.GetIsolate
()->GetCurrentContext(), v8_str("x"), v8_num(1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 963, "Check failed: %s."
, "info.This() ->Set(info.GetIsolate()->GetCurrentContext(), v8_str(\"x\"), v8_num(1)) .FromJust()"
); } } while (0)
961 info.This()do { if ((__builtin_expect(!!(!(info.This() ->Set(info.GetIsolate
()->GetCurrentContext(), v8_str("x"), v8_num(1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 963, "Check failed: %s."
, "info.This() ->Set(info.GetIsolate()->GetCurrentContext(), v8_str(\"x\"), v8_num(1)) .FromJust()"
); } } while (0)
962 ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("x"), v8_num(1))do { if ((__builtin_expect(!!(!(info.This() ->Set(info.GetIsolate
()->GetCurrentContext(), v8_str("x"), v8_num(1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 963, "Check failed: %s."
, "info.This() ->Set(info.GetIsolate()->GetCurrentContext(), v8_str(\"x\"), v8_num(1)) .FromJust()"
); } } while (0)
963 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Set(info.GetIsolate
()->GetCurrentContext(), v8_str("x"), v8_num(1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 963, "Check failed: %s."
, "info.This() ->Set(info.GetIsolate()->GetCurrentContext(), v8_str(\"x\"), v8_num(1)) .FromJust()"
); } } while (0)
;
964 CHECK(do { if ((__builtin_expect(!!(!(info.This() ->Set(info.GetIsolate
()->GetCurrentContext(), v8_str("y"), v8_num(2)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 967, "Check failed: %s."
, "info.This() ->Set(info.GetIsolate()->GetCurrentContext(), v8_str(\"y\"), v8_num(2)) .FromJust()"
); } } while (0)
965 info.This()do { if ((__builtin_expect(!!(!(info.This() ->Set(info.GetIsolate
()->GetCurrentContext(), v8_str("y"), v8_num(2)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 967, "Check failed: %s."
, "info.This() ->Set(info.GetIsolate()->GetCurrentContext(), v8_str(\"y\"), v8_num(2)) .FromJust()"
); } } while (0)
966 ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(2))do { if ((__builtin_expect(!!(!(info.This() ->Set(info.GetIsolate
()->GetCurrentContext(), v8_str("y"), v8_num(2)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 967, "Check failed: %s."
, "info.This() ->Set(info.GetIsolate()->GetCurrentContext(), v8_str(\"y\"), v8_num(2)) .FromJust()"
); } } while (0)
967 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Set(info.GetIsolate
()->GetCurrentContext(), v8_str("y"), v8_num(2)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 967, "Check failed: %s."
, "info.This() ->Set(info.GetIsolate()->GetCurrentContext(), v8_str(\"y\"), v8_num(2)) .FromJust()"
); } } while (0)
;
968 info.GetReturnValue().Set(v8_str("bad value"));
969 info.GetReturnValue().Set(info.This());
970}
971
972
973static void Return239Callback(
974 Local<String> name, const v8::PropertyCallbackInfo<Value>& info) {
975 ApiTestFuzzer::Fuzz();
976 CheckReturnValue(info, FUNCTION_ADDR(Return239Callback)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(Return239Callback)))
);
977 info.GetReturnValue().Set(v8_str("bad value"));
978 info.GetReturnValue().Set(v8_num(239));
979}
980
981
982template<typename Handler>
983static void TestFunctionTemplateInitializer(Handler handler,
984 Handler handler_2) {
985 // Test constructor calls.
986 {
987 LocalContext env;
988 v8::Isolate* isolate = env->GetIsolate();
989 v8::HandleScope scope(isolate);
990
991 Local<v8::FunctionTemplate> fun_templ =
992 v8::FunctionTemplate::New(isolate, handler);
993 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
994 CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("obj"), fun).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 994, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"obj\"), fun).FromJust()"
); } } while (0)
;
995 Local<Script> script = v8_compile("obj()");
996 for (int i = 0; i < 30; i++) {
997 CHECK_EQ(102, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (102), (
v8_run_int32value(script)), "102" " " "==" " " "v8_run_int32value(script)"
)) { V8_Fatal("../test/cctest/test-api.cc", 997, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
998 }
999 }
1000 // Use SetCallHandler to initialize a function template, should work like
1001 // the previous one.
1002 {
1003 LocalContext env;
1004 v8::Isolate* isolate = env->GetIsolate();
1005 v8::HandleScope scope(isolate);
1006
1007 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
1008 fun_templ->SetCallHandler(handler_2);
1009 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
1010 CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("obj"), fun).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1010, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"obj\"), fun).FromJust()"
); } } while (0)
;
1011 Local<Script> script = v8_compile("obj()");
1012 for (int i = 0; i < 30; i++) {
1013 CHECK_EQ(102, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (102), (
v8_run_int32value(script)), "102" " " "==" " " "v8_run_int32value(script)"
)) { V8_Fatal("../test/cctest/test-api.cc", 1013, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1014 }
1015 }
1016}
1017
1018
1019template<typename Constructor, typename Accessor>
1020static void TestFunctionTemplateAccessor(Constructor constructor,
1021 Accessor accessor) {
1022 LocalContext env;
1023 v8::HandleScope scope(env->GetIsolate());
1024
1025 Local<v8::FunctionTemplate> fun_templ =
1026 v8::FunctionTemplate::New(env->GetIsolate(), constructor);
1027 fun_templ->SetClassName(v8_str("funky"));
1028 fun_templ->InstanceTemplate()->SetAccessor(v8_str("m"), accessor);
1029 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
1030 CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("obj"), fun).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1030, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"obj\"), fun).FromJust()"
); } } while (0)
;
1031 Local<Value> result =
1032 v8_compile("(new obj()).toString()")->Run(env.local()).ToLocalChecked();
1033 CHECK(v8_str("[object funky]")->Equals(env.local(), result).FromJust())do { if ((__builtin_expect(!!(!(v8_str("[object funky]")->
Equals(env.local(), result).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1033, "Check failed: %s.", "v8_str(\"[object funky]\")->Equals(env.local(), result).FromJust()"
); } } while (0)
;
1034 CompileRun("var obj_instance = new obj();");
1035 Local<Script> script;
1036 script = v8_compile("obj_instance.x");
1037 for (int i = 0; i < 30; i++) {
1038 CHECK_EQ(1, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (v8_run_int32value
(script)), "1" " " "==" " " "v8_run_int32value(script)")) { V8_Fatal
("../test/cctest/test-api.cc", 1038, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
1039 }
1040 script = v8_compile("obj_instance.m");
1041 for (int i = 0; i < 30; i++) {
1042 CHECK_EQ(239, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (239), (
v8_run_int32value(script)), "239" " " "==" " " "v8_run_int32value(script)"
)) { V8_Fatal("../test/cctest/test-api.cc", 1042, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1043 }
1044}
1045
1046
1047THREADED_PROFILED_TEST(FunctionTemplate)static void TestFunctionTemplate(); static void TestFunctionTemplateWithProfiler
(); CcTest register_test_FunctionTemplateWithProfiler(TestFunctionTemplateWithProfiler
, "../test/cctest/test-api.cc", "FunctionTemplateWithProfiler"
, __null, true, true); static void TestFunctionTemplateWithProfiler
() { RunWithProfiler(&TestFunctionTemplate); } static void
TestFunctionTemplate(); RegisterThreadedTest register_FunctionTemplate
(TestFunctionTemplate, "FunctionTemplate"); static void TestFunctionTemplate
(); CcTest register_test_FunctionTemplate(TestFunctionTemplate
, "../test/cctest/test-api.cc", "FunctionTemplate", __null, true
, true); static void TestFunctionTemplate()
{
1048 TestFunctionTemplateInitializer(handle_callback, handle_callback_2);
1049 TestFunctionTemplateAccessor(construct_callback, Return239Callback);
1050}
1051
1052
1053static void SimpleCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
1054 ApiTestFuzzer::Fuzz();
1055 CheckReturnValue(info, FUNCTION_ADDR(SimpleCallback)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(SimpleCallback)))
);
1056 info.GetReturnValue().Set(v8_num(51423 + info.Length()));
1057}
1058
1059
1060template<typename Callback>
1061static void TestSimpleCallback(Callback callback) {
1062 LocalContext env;
1063 v8::Isolate* isolate = env->GetIsolate();
1064 v8::HandleScope scope(isolate);
1065
1066 v8::Local<v8::ObjectTemplate> object_template =
1067 v8::ObjectTemplate::New(isolate);
1068 object_template->Set(isolate, "callback",
1069 v8::FunctionTemplate::New(isolate, callback));
1070 v8::Local<v8::Object> object =
1071 object_template->NewInstance(env.local()).ToLocalChecked();
1072 CHECK((*env)do { if ((__builtin_expect(!!(!((*env) ->Global() ->Set
(env.local(), v8_str("callback_object"), object) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1075, "Check failed: %s."
, "(*env) ->Global() ->Set(env.local(), v8_str(\"callback_object\"), object) .FromJust()"
); } } while (0)
1073 ->Global()do { if ((__builtin_expect(!!(!((*env) ->Global() ->Set
(env.local(), v8_str("callback_object"), object) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1075, "Check failed: %s."
, "(*env) ->Global() ->Set(env.local(), v8_str(\"callback_object\"), object) .FromJust()"
); } } while (0)
1074 ->Set(env.local(), v8_str("callback_object"), object)do { if ((__builtin_expect(!!(!((*env) ->Global() ->Set
(env.local(), v8_str("callback_object"), object) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1075, "Check failed: %s."
, "(*env) ->Global() ->Set(env.local(), v8_str(\"callback_object\"), object) .FromJust()"
); } } while (0)
1075 .FromJust())do { if ((__builtin_expect(!!(!((*env) ->Global() ->Set
(env.local(), v8_str("callback_object"), object) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1075, "Check failed: %s."
, "(*env) ->Global() ->Set(env.local(), v8_str(\"callback_object\"), object) .FromJust()"
); } } while (0)
;
1076 v8::Local<v8::Script> script;
1077 script = v8_compile("callback_object.callback(17)");
1078 for (int i = 0; i < 30; i++) {
1079 CHECK_EQ(51424, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (51424)
, (v8_run_int32value(script)), "51424" " " "==" " " "v8_run_int32value(script)"
)) { V8_Fatal("../test/cctest/test-api.cc", 1079, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1080 }
1081 script = v8_compile("callback_object.callback(17, 24)");
1082 for (int i = 0; i < 30; i++) {
1083 CHECK_EQ(51425, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (51425)
, (v8_run_int32value(script)), "51425" " " "==" " " "v8_run_int32value(script)"
)) { V8_Fatal("../test/cctest/test-api.cc", 1083, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1084 }
1085}
1086
1087
1088THREADED_PROFILED_TEST(SimpleCallback)static void TestSimpleCallback(); static void TestSimpleCallbackWithProfiler
(); CcTest register_test_SimpleCallbackWithProfiler(TestSimpleCallbackWithProfiler
, "../test/cctest/test-api.cc", "SimpleCallbackWithProfiler",
__null, true, true); static void TestSimpleCallbackWithProfiler
() { RunWithProfiler(&TestSimpleCallback); } static void TestSimpleCallback
(); RegisterThreadedTest register_SimpleCallback(TestSimpleCallback
, "SimpleCallback"); static void TestSimpleCallback(); CcTest
register_test_SimpleCallback(TestSimpleCallback, "../test/cctest/test-api.cc"
, "SimpleCallback", __null, true, true); static void TestSimpleCallback
()
{
1089 TestSimpleCallback(SimpleCallback);
1090}
1091
1092
1093template<typename T>
1094void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info);
1095
1096// constant return values
1097static int32_t fast_return_value_int32 = 471;
1098static uint32_t fast_return_value_uint32 = 571;
1099static const double kFastReturnValueDouble = 2.7;
1100// variable return values
1101static bool fast_return_value_bool = false;
1102enum ReturnValueOddball {
1103 kNullReturnValue,
1104 kUndefinedReturnValue,
1105 kEmptyStringReturnValue
1106};
1107static ReturnValueOddball fast_return_value_void;
1108static bool fast_return_value_object_is_empty = false;
1109
1110// Helper function to avoid compiler error: insufficient contextual information
1111// to determine type when applying FUNCTION_ADDR to a template function.
1112static i::Address address_of(v8::FunctionCallback callback) {
1113 return FUNCTION_ADDR(callback)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(callback)))
;
1114}
1115
1116template<>
1117void FastReturnValueCallback<int32_t>(
1118 const v8::FunctionCallbackInfo<v8::Value>& info) {
1119 CheckReturnValue(info, address_of(FastReturnValueCallback<int32_t>));
1120 info.GetReturnValue().Set(fast_return_value_int32);
1121}
1122
1123template<>
1124void FastReturnValueCallback<uint32_t>(
1125 const v8::FunctionCallbackInfo<v8::Value>& info) {
1126 CheckReturnValue(info, address_of(FastReturnValueCallback<uint32_t>));
1127 info.GetReturnValue().Set(fast_return_value_uint32);
1128}
1129
1130template<>
1131void FastReturnValueCallback<double>(
1132 const v8::FunctionCallbackInfo<v8::Value>& info) {
1133 CheckReturnValue(info, address_of(FastReturnValueCallback<double>));
1134 info.GetReturnValue().Set(kFastReturnValueDouble);
1135}
1136
1137template<>
1138void FastReturnValueCallback<bool>(
1139 const v8::FunctionCallbackInfo<v8::Value>& info) {
1140 CheckReturnValue(info, address_of(FastReturnValueCallback<bool>));
1141 info.GetReturnValue().Set(fast_return_value_bool);
1142}
1143
1144template<>
1145void FastReturnValueCallback<void>(
1146 const v8::FunctionCallbackInfo<v8::Value>& info) {
1147 CheckReturnValue(info, address_of(FastReturnValueCallback<void>));
1148 switch (fast_return_value_void) {
1149 case kNullReturnValue:
1150 info.GetReturnValue().SetNull();
1151 break;
1152 case kUndefinedReturnValue:
1153 info.GetReturnValue().SetUndefined();
1154 break;
1155 case kEmptyStringReturnValue:
1156 info.GetReturnValue().SetEmptyString();
1157 break;
1158 }
1159}
1160
1161template<>
1162void FastReturnValueCallback<Object>(
1163 const v8::FunctionCallbackInfo<v8::Value>& info) {
1164 v8::Local<v8::Object> object;
1165 if (!fast_return_value_object_is_empty) {
1166 object = Object::New(info.GetIsolate());
1167 }
1168 info.GetReturnValue().Set(object);
1169}
1170
1171template <typename T>
1172Local<Value> TestFastReturnValues() {
1173 LocalContext env;
1174 v8::Isolate* isolate = env->GetIsolate();
1175 v8::EscapableHandleScope scope(isolate);
1176 v8::Local<v8::ObjectTemplate> object_template =
1177 v8::ObjectTemplate::New(isolate);
1178 v8::FunctionCallback callback = &FastReturnValueCallback<T>;
1179 object_template->Set(isolate, "callback",
1180 v8::FunctionTemplate::New(isolate, callback));
1181 v8::Local<v8::Object> object =
1182 object_template->NewInstance(env.local()).ToLocalChecked();
1183 CHECK((*env)do { if ((__builtin_expect(!!(!((*env) ->Global() ->Set
(env.local(), v8_str("callback_object"), object) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1186, "Check failed: %s."
, "(*env) ->Global() ->Set(env.local(), v8_str(\"callback_object\"), object) .FromJust()"
); } } while (0)
1184 ->Global()do { if ((__builtin_expect(!!(!((*env) ->Global() ->Set
(env.local(), v8_str("callback_object"), object) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1186, "Check failed: %s."
, "(*env) ->Global() ->Set(env.local(), v8_str(\"callback_object\"), object) .FromJust()"
); } } while (0)
1185 ->Set(env.local(), v8_str("callback_object"), object)do { if ((__builtin_expect(!!(!((*env) ->Global() ->Set
(env.local(), v8_str("callback_object"), object) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1186, "Check failed: %s."
, "(*env) ->Global() ->Set(env.local(), v8_str(\"callback_object\"), object) .FromJust()"
); } } while (0)
1186 .FromJust())do { if ((__builtin_expect(!!(!((*env) ->Global() ->Set
(env.local(), v8_str("callback_object"), object) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1186, "Check failed: %s."
, "(*env) ->Global() ->Set(env.local(), v8_str(\"callback_object\"), object) .FromJust()"
); } } while (0)
;
1187 return scope.Escape(CompileRun("callback_object.callback()"));
1188}
1189
1190
1191THREADED_PROFILED_TEST(FastReturnValues)static void TestFastReturnValues(); static void TestFastReturnValuesWithProfiler
(); CcTest register_test_FastReturnValuesWithProfiler(TestFastReturnValuesWithProfiler
, "../test/cctest/test-api.cc", "FastReturnValuesWithProfiler"
, __null, true, true); static void TestFastReturnValuesWithProfiler
() { RunWithProfiler(&TestFastReturnValues); } static void
TestFastReturnValues(); RegisterThreadedTest register_FastReturnValues
(TestFastReturnValues, "FastReturnValues"); static void TestFastReturnValues
(); CcTest register_test_FastReturnValues(TestFastReturnValues
, "../test/cctest/test-api.cc", "FastReturnValues", __null, true
, true); static void TestFastReturnValues()
{
1192 LocalContext env;
1193 v8::Isolate* isolate = env->GetIsolate();
1194 v8::HandleScope scope(isolate);
1195 v8::Local<v8::Value> value;
1196 // check int32_t and uint32_t
1197 int32_t int_values[] = {
1198 0, 234, -723,
1199 i::Smi::kMinValue, i::Smi::kMaxValue
1200 };
1201 for (size_t i = 0; i < arraysize(int_values)(sizeof(ArraySizeHelper(int_values))); i++) {
1202 for (int modifier = -1; modifier <= 1; modifier++) {
1203 int int_value = int_values[i] + modifier;
1204 // check int32_t
1205 fast_return_value_int32 = int_value;
1206 value = TestFastReturnValues<int32_t>();
1207 CHECK(value->IsInt32())do { if ((__builtin_expect(!!(!(value->IsInt32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1207, "Check failed: %s."
, "value->IsInt32()"); } } while (0)
;
1208 CHECK_EQ(fast_return_value_int32,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (fast_return_value_int32
), (value->Int32Value(env.local()).FromJust()), "fast_return_value_int32"
" " "==" " " "value->Int32Value(env.local()).FromJust()")
) { V8_Fatal("../test/cctest/test-api.cc", 1209, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
1209 value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (fast_return_value_int32
), (value->Int32Value(env.local()).FromJust()), "fast_return_value_int32"
" " "==" " " "value->Int32Value(env.local()).FromJust()")
) { V8_Fatal("../test/cctest/test-api.cc", 1209, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1210 // check uint32_t
1211 fast_return_value_uint32 = static_cast<uint32_t>(int_value);
1212 value = TestFastReturnValues<uint32_t>();
1213 CHECK(value->IsUint32())do { if ((__builtin_expect(!!(!(value->IsUint32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1213, "Check failed: %s."
, "value->IsUint32()"); } } while (0)
;
1214 CHECK_EQ(fast_return_value_uint32,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (fast_return_value_uint32
), (value->Uint32Value(env.local()).FromJust()), "fast_return_value_uint32"
" " "==" " " "value->Uint32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1215, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
1215 value->Uint32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (fast_return_value_uint32
), (value->Uint32Value(env.local()).FromJust()), "fast_return_value_uint32"
" " "==" " " "value->Uint32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1215, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1216 }
1217 }
1218 // check double
1219 value = TestFastReturnValues<double>();
1220 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1220, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
1221 CHECK_EQ(kFastReturnValueDouble,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kFastReturnValueDouble
), (value->ToNumber(env.local()).ToLocalChecked()->Value
()), "kFastReturnValueDouble" " " "==" " " "value->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1222, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
1222 value->ToNumber(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kFastReturnValueDouble
), (value->ToNumber(env.local()).ToLocalChecked()->Value
()), "kFastReturnValueDouble" " " "==" " " "value->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1222, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1223 // check bool values
1224 for (int i = 0; i < 2; i++) {
1225 fast_return_value_bool = i == 0;
1226 value = TestFastReturnValues<bool>();
1227 CHECK(value->IsBoolean())do { if ((__builtin_expect(!!(!(value->IsBoolean())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 1227, "Check failed: %s."
, "value->IsBoolean()"); } } while (0)
;
1228 CHECK_EQ(fast_return_value_bool,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (fast_return_value_bool
), (value->ToBoolean(env.local()).ToLocalChecked()->Value
()), "fast_return_value_bool" " " "==" " " "value->ToBoolean(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1229, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
1229 value->ToBoolean(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (fast_return_value_bool
), (value->ToBoolean(env.local()).ToLocalChecked()->Value
()), "fast_return_value_bool" " " "==" " " "value->ToBoolean(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1229, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1230 }
1231 // check oddballs
1232 ReturnValueOddball oddballs[] = {
1233 kNullReturnValue,
1234 kUndefinedReturnValue,
1235 kEmptyStringReturnValue
1236 };
1237 for (size_t i = 0; i < arraysize(oddballs)(sizeof(ArraySizeHelper(oddballs))); i++) {
1238 fast_return_value_void = oddballs[i];
1239 value = TestFastReturnValues<void>();
1240 switch (fast_return_value_void) {
1241 case kNullReturnValue:
1242 CHECK(value->IsNull())do { if ((__builtin_expect(!!(!(value->IsNull())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1242, "Check failed: %s.", "value->IsNull()"
); } } while (0)
;
1243 break;
1244 case kUndefinedReturnValue:
1245 CHECK(value->IsUndefined())do { if ((__builtin_expect(!!(!(value->IsUndefined())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1245, "Check failed: %s."
, "value->IsUndefined()"); } } while (0)
;
1246 break;
1247 case kEmptyStringReturnValue:
1248 CHECK(value->IsString())do { if ((__builtin_expect(!!(!(value->IsString())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1248, "Check failed: %s."
, "value->IsString()"); } } while (0)
;
1249 CHECK_EQ(0, v8::String::Cast(*value)->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (v8
::String::Cast(*value)->Length()), "0" " " "==" " " "v8::String::Cast(*value)->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1249, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1250 break;
1251 }
1252 }
1253 // check handles
1254 fast_return_value_object_is_empty = false;
1255 value = TestFastReturnValues<Object>();
1256 CHECK(value->IsObject())do { if ((__builtin_expect(!!(!(value->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1256, "Check failed: %s."
, "value->IsObject()"); } } while (0)
;
1257 fast_return_value_object_is_empty = true;
1258 value = TestFastReturnValues<Object>();
1259 CHECK(value->IsUndefined())do { if ((__builtin_expect(!!(!(value->IsUndefined())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1259, "Check failed: %s."
, "value->IsUndefined()"); } } while (0)
;
1260}
1261
1262
1263THREADED_TEST(FunctionTemplateSetLength)static void TestFunctionTemplateSetLength(); RegisterThreadedTest
register_FunctionTemplateSetLength(TestFunctionTemplateSetLength
, "FunctionTemplateSetLength"); static void TestFunctionTemplateSetLength
(); CcTest register_test_FunctionTemplateSetLength(TestFunctionTemplateSetLength
, "../test/cctest/test-api.cc", "FunctionTemplateSetLength", __null
, true, true); static void TestFunctionTemplateSetLength()
{
1264 LocalContext env;
1265 v8::Isolate* isolate = env->GetIsolate();
1266 v8::HandleScope scope(isolate);
1267 {
1268 Local<v8::FunctionTemplate> fun_templ =
1269 v8::FunctionTemplate::New(isolate, handle_callback, Local<v8::Value>(),
1270 Local<v8::Signature>(), 23);
1271 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
1272 CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("obj"), fun).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1272, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"obj\"), fun).FromJust()"
); } } while (0)
;
1273 Local<Script> script = v8_compile("obj.length");
1274 CHECK_EQ(23, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
v8_run_int32value(script)), "23" " " "==" " " "v8_run_int32value(script)"
)) { V8_Fatal("../test/cctest/test-api.cc", 1274, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1275 }
1276 {
1277 Local<v8::FunctionTemplate> fun_templ =
1278 v8::FunctionTemplate::New(isolate, handle_callback);
1279 fun_templ->SetLength(22);
1280 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
1281 CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("obj"), fun).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1281, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"obj\"), fun).FromJust()"
); } } while (0)
;
1282 Local<Script> script = v8_compile("obj.length");
1283 CHECK_EQ(22, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (22), (
v8_run_int32value(script)), "22" " " "==" " " "v8_run_int32value(script)"
)) { V8_Fatal("../test/cctest/test-api.cc", 1283, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1284 }
1285 {
1286 // Without setting length it defaults to 0.
1287 Local<v8::FunctionTemplate> fun_templ =
1288 v8::FunctionTemplate::New(isolate, handle_callback);
1289 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
1290 CHECK(env->Global()->Set(env.local(), v8_str("obj"), fun).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("obj"), fun).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1290, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"obj\"), fun).FromJust()"
); } } while (0)
;
1291 Local<Script> script = v8_compile("obj.length");
1292 CHECK_EQ(0, v8_run_int32value(script))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (v8_run_int32value
(script)), "0" " " "==" " " "v8_run_int32value(script)")) { V8_Fatal
("../test/cctest/test-api.cc", 1292, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
1293 }
1294}
1295
1296
1297static void* expected_ptr;
1298static void callback(const v8::FunctionCallbackInfo<v8::Value>& args) {
1299 void* ptr = v8::External::Cast(*args.Data())->Value();
1300 CHECK_EQ(expected_ptr, ptr)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected_ptr
), (ptr), "expected_ptr" " " "==" " " "ptr")) { V8_Fatal("../test/cctest/test-api.cc"
, 1300, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1301 args.GetReturnValue().Set(true);
1302}
1303
1304
1305static void TestExternalPointerWrapping() {
1306 LocalContext env;
1307 v8::Isolate* isolate = env->GetIsolate();
1308 v8::HandleScope scope(isolate);
1309
1310 v8::Local<v8::Value> data = v8::External::New(isolate, expected_ptr);
1311
1312 v8::Local<v8::Object> obj = v8::Object::New(isolate);
1313 CHECK(obj->Set(env.local(), v8_str("func"),do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8_str
("func"), v8::FunctionTemplate::New(isolate, callback, data) ->
GetFunction(env.local()) .ToLocalChecked()) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1317, "Check failed: %s."
, "obj->Set(env.local(), v8_str(\"func\"), v8::FunctionTemplate::New(isolate, callback, data) ->GetFunction(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
1314 v8::FunctionTemplate::New(isolate, callback, data)do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8_str
("func"), v8::FunctionTemplate::New(isolate, callback, data) ->
GetFunction(env.local()) .ToLocalChecked()) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1317, "Check failed: %s."
, "obj->Set(env.local(), v8_str(\"func\"), v8::FunctionTemplate::New(isolate, callback, data) ->GetFunction(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
1315 ->GetFunction(env.local())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8_str
("func"), v8::FunctionTemplate::New(isolate, callback, data) ->
GetFunction(env.local()) .ToLocalChecked()) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1317, "Check failed: %s."
, "obj->Set(env.local(), v8_str(\"func\"), v8::FunctionTemplate::New(isolate, callback, data) ->GetFunction(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
1316 .ToLocalChecked())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8_str
("func"), v8::FunctionTemplate::New(isolate, callback, data) ->
GetFunction(env.local()) .ToLocalChecked()) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1317, "Check failed: %s."
, "obj->Set(env.local(), v8_str(\"func\"), v8::FunctionTemplate::New(isolate, callback, data) ->GetFunction(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
1317 .FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8_str
("func"), v8::FunctionTemplate::New(isolate, callback, data) ->
GetFunction(env.local()) .ToLocalChecked()) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1317, "Check failed: %s."
, "obj->Set(env.local(), v8_str(\"func\"), v8::FunctionTemplate::New(isolate, callback, data) ->GetFunction(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
1318 CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("obj"), obj).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1318, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"obj\"), obj).FromJust()"
); } } while (0)
;
1319
1320 CHECK(CompileRun("function foo() {\n"do { if ((__builtin_expect(!!(!(CompileRun("function foo() {\n"
" for (var i = 0; i < 13; i++) obj.func();\n" "}\n" "foo(), true"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1325, "Check failed: %s.", "CompileRun(\"function foo() {\\n\" \" for (var i = 0; i < 13; i++) obj.func();\\n\" \"}\\n\" \"foo(), true\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1321 " for (var i = 0; i < 13; i++) obj.func();\n"do { if ((__builtin_expect(!!(!(CompileRun("function foo() {\n"
" for (var i = 0; i < 13; i++) obj.func();\n" "}\n" "foo(), true"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1325, "Check failed: %s.", "CompileRun(\"function foo() {\\n\" \" for (var i = 0; i < 13; i++) obj.func();\\n\" \"}\\n\" \"foo(), true\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1322 "}\n"do { if ((__builtin_expect(!!(!(CompileRun("function foo() {\n"
" for (var i = 0; i < 13; i++) obj.func();\n" "}\n" "foo(), true"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1325, "Check failed: %s.", "CompileRun(\"function foo() {\\n\" \" for (var i = 0; i < 13; i++) obj.func();\\n\" \"}\\n\" \"foo(), true\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1323 "foo(), true")do { if ((__builtin_expect(!!(!(CompileRun("function foo() {\n"
" for (var i = 0; i < 13; i++) obj.func();\n" "}\n" "foo(), true"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1325, "Check failed: %s.", "CompileRun(\"function foo() {\\n\" \" for (var i = 0; i < 13; i++) obj.func();\\n\" \"}\\n\" \"foo(), true\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1324 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(CompileRun("function foo() {\n"
" for (var i = 0; i < 13; i++) obj.func();\n" "}\n" "foo(), true"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1325, "Check failed: %s.", "CompileRun(\"function foo() {\\n\" \" for (var i = 0; i < 13; i++) obj.func();\\n\" \"}\\n\" \"foo(), true\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1325 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("function foo() {\n"
" for (var i = 0; i < 13; i++) obj.func();\n" "}\n" "foo(), true"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1325, "Check failed: %s.", "CompileRun(\"function foo() {\\n\" \" for (var i = 0; i < 13; i++) obj.func();\\n\" \"}\\n\" \"foo(), true\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
1326}
1327
1328
1329THREADED_TEST(ExternalWrap)static void TestExternalWrap(); RegisterThreadedTest register_ExternalWrap
(TestExternalWrap, "ExternalWrap"); static void TestExternalWrap
(); CcTest register_test_ExternalWrap(TestExternalWrap, "../test/cctest/test-api.cc"
, "ExternalWrap", __null, true, true); static void TestExternalWrap
()
{
1330 // Check heap allocated object.
1331 int* ptr = new int;
1332 expected_ptr = ptr;
1333 TestExternalPointerWrapping();
1334 delete ptr;
1335
1336 // Check stack allocated object.
1337 int foo;
1338 expected_ptr = &foo;
1339 TestExternalPointerWrapping();
1340
1341 // Check not aligned addresses.
1342 const int n = 100;
1343 char* s = new char[n];
1344 for (int i = 0; i < n; i++) {
1345 expected_ptr = s + i;
1346 TestExternalPointerWrapping();
1347 }
1348
1349 delete[] s;
1350
1351 // Check several invalid addresses.
1352 expected_ptr = reinterpret_cast<void*>(1);
1353 TestExternalPointerWrapping();
1354
1355 expected_ptr = reinterpret_cast<void*>(0xdeadbeef);
1356 TestExternalPointerWrapping();
1357
1358 expected_ptr = reinterpret_cast<void*>(0xdeadbeef + 1);
1359 TestExternalPointerWrapping();
1360
1361#if defined(V8_HOST_ARCH_X641)
1362 // Check a value with a leading 1 bit in x64 Smi encoding.
1363 expected_ptr = reinterpret_cast<void*>(0x400000000);
1364 TestExternalPointerWrapping();
1365
1366 expected_ptr = reinterpret_cast<void*>(0xdeadbeefdeadbeef);
1367 TestExternalPointerWrapping();
1368
1369 expected_ptr = reinterpret_cast<void*>(0xdeadbeefdeadbeef + 1);
1370 TestExternalPointerWrapping();
1371#endif
1372}
1373
1374
1375THREADED_TEST(FindInstanceInPrototypeChain)static void TestFindInstanceInPrototypeChain(); RegisterThreadedTest
register_FindInstanceInPrototypeChain(TestFindInstanceInPrototypeChain
, "FindInstanceInPrototypeChain"); static void TestFindInstanceInPrototypeChain
(); CcTest register_test_FindInstanceInPrototypeChain(TestFindInstanceInPrototypeChain
, "../test/cctest/test-api.cc", "FindInstanceInPrototypeChain"
, __null, true, true); static void TestFindInstanceInPrototypeChain
()
{
1376 LocalContext env;
1377 v8::Isolate* isolate = env->GetIsolate();
1378 v8::HandleScope scope(isolate);
1379
1380 Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New(isolate);
1381 Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New(isolate);
1382 Local<v8::FunctionTemplate> other = v8::FunctionTemplate::New(isolate);
1383 derived->Inherit(base);
1384
1385 Local<v8::Function> base_function =
1386 base->GetFunction(env.local()).ToLocalChecked();
1387 Local<v8::Function> derived_function =
1388 derived->GetFunction(env.local()).ToLocalChecked();
1389 Local<v8::Function> other_function =
1390 other->GetFunction(env.local()).ToLocalChecked();
1391
1392 Local<v8::Object> base_instance =
1393 base_function->NewInstance(env.local()).ToLocalChecked();
1394 Local<v8::Object> derived_instance =
1395 derived_function->NewInstance(env.local()).ToLocalChecked();
1396 Local<v8::Object> derived_instance2 =
1397 derived_function->NewInstance(env.local()).ToLocalChecked();
1398 Local<v8::Object> other_instance =
1399 other_function->NewInstance(env.local()).ToLocalChecked();
1400 CHECK(do { if ((__builtin_expect(!!(!(derived_instance2->Set(env
.local(), v8_str("__proto__"), derived_instance) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1402, "Check failed: %s."
, "derived_instance2->Set(env.local(), v8_str(\"__proto__\"), derived_instance) .FromJust()"
); } } while (0)
1401 derived_instance2->Set(env.local(), v8_str("__proto__"), derived_instance)do { if ((__builtin_expect(!!(!(derived_instance2->Set(env
.local(), v8_str("__proto__"), derived_instance) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1402, "Check failed: %s."
, "derived_instance2->Set(env.local(), v8_str(\"__proto__\"), derived_instance) .FromJust()"
); } } while (0)
1402 .FromJust())do { if ((__builtin_expect(!!(!(derived_instance2->Set(env
.local(), v8_str("__proto__"), derived_instance) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1402, "Check failed: %s."
, "derived_instance2->Set(env.local(), v8_str(\"__proto__\"), derived_instance) .FromJust()"
); } } while (0)
;
1403 CHECK(other_instance->Set(env.local(), v8_str("__proto__"), derived_instance2)do { if ((__builtin_expect(!!(!(other_instance->Set(env.local
(), v8_str("__proto__"), derived_instance2) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1404, "Check failed: %s."
, "other_instance->Set(env.local(), v8_str(\"__proto__\"), derived_instance2) .FromJust()"
); } } while (0)
1404 .FromJust())do { if ((__builtin_expect(!!(!(other_instance->Set(env.local
(), v8_str("__proto__"), derived_instance2) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1404, "Check failed: %s."
, "other_instance->Set(env.local(), v8_str(\"__proto__\"), derived_instance2) .FromJust()"
); } } while (0)
;
1405
1406 // base_instance is only an instance of base.
1407 CHECK(base_instance->Equals(env.local(),do { if ((__builtin_expect(!!(!(base_instance->Equals(env.
local(), base_instance->FindInstanceInPrototypeChain(base)
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1409, "Check failed: %s.", "base_instance->Equals(env.local(), base_instance->FindInstanceInPrototypeChain(base)) .FromJust()"
); } } while (0)
1408 base_instance->FindInstanceInPrototypeChain(base))do { if ((__builtin_expect(!!(!(base_instance->Equals(env.
local(), base_instance->FindInstanceInPrototypeChain(base)
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1409, "Check failed: %s.", "base_instance->Equals(env.local(), base_instance->FindInstanceInPrototypeChain(base)) .FromJust()"
); } } while (0)
1409 .FromJust())do { if ((__builtin_expect(!!(!(base_instance->Equals(env.
local(), base_instance->FindInstanceInPrototypeChain(base)
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1409, "Check failed: %s.", "base_instance->Equals(env.local(), base_instance->FindInstanceInPrototypeChain(base)) .FromJust()"
); } } while (0)
;
1410 CHECK(base_instance->FindInstanceInPrototypeChain(derived).IsEmpty())do { if ((__builtin_expect(!!(!(base_instance->FindInstanceInPrototypeChain
(derived).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1410, "Check failed: %s.", "base_instance->FindInstanceInPrototypeChain(derived).IsEmpty()"
); } } while (0)
;
1411 CHECK(base_instance->FindInstanceInPrototypeChain(other).IsEmpty())do { if ((__builtin_expect(!!(!(base_instance->FindInstanceInPrototypeChain
(other).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1411, "Check failed: %s.", "base_instance->FindInstanceInPrototypeChain(other).IsEmpty()"
); } } while (0)
;
1412
1413 // derived_instance is an instance of base and derived.
1414 CHECK(derived_instance->Equals(env.local(),do { if ((__builtin_expect(!!(!(derived_instance->Equals(env
.local(), derived_instance->FindInstanceInPrototypeChain( base
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1417, "Check failed: %s.", "derived_instance->Equals(env.local(), derived_instance->FindInstanceInPrototypeChain( base)) .FromJust()"
); } } while (0)
1415 derived_instance->FindInstanceInPrototypeChain(do { if ((__builtin_expect(!!(!(derived_instance->Equals(env
.local(), derived_instance->FindInstanceInPrototypeChain( base
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1417, "Check failed: %s.", "derived_instance->Equals(env.local(), derived_instance->FindInstanceInPrototypeChain( base)) .FromJust()"
); } } while (0)
1416 base))do { if ((__builtin_expect(!!(!(derived_instance->Equals(env
.local(), derived_instance->FindInstanceInPrototypeChain( base
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1417, "Check failed: %s.", "derived_instance->Equals(env.local(), derived_instance->FindInstanceInPrototypeChain( base)) .FromJust()"
); } } while (0)
1417 .FromJust())do { if ((__builtin_expect(!!(!(derived_instance->Equals(env
.local(), derived_instance->FindInstanceInPrototypeChain( base
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1417, "Check failed: %s.", "derived_instance->Equals(env.local(), derived_instance->FindInstanceInPrototypeChain( base)) .FromJust()"
); } } while (0)
;
1418 CHECK(derived_instance->Equals(env.local(),do { if ((__builtin_expect(!!(!(derived_instance->Equals(env
.local(), derived_instance->FindInstanceInPrototypeChain( derived
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1421, "Check failed: %s.", "derived_instance->Equals(env.local(), derived_instance->FindInstanceInPrototypeChain( derived)) .FromJust()"
); } } while (0)
1419 derived_instance->FindInstanceInPrototypeChain(do { if ((__builtin_expect(!!(!(derived_instance->Equals(env
.local(), derived_instance->FindInstanceInPrototypeChain( derived
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1421, "Check failed: %s.", "derived_instance->Equals(env.local(), derived_instance->FindInstanceInPrototypeChain( derived)) .FromJust()"
); } } while (0)
1420 derived))do { if ((__builtin_expect(!!(!(derived_instance->Equals(env
.local(), derived_instance->FindInstanceInPrototypeChain( derived
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1421, "Check failed: %s.", "derived_instance->Equals(env.local(), derived_instance->FindInstanceInPrototypeChain( derived)) .FromJust()"
); } } while (0)
1421 .FromJust())do { if ((__builtin_expect(!!(!(derived_instance->Equals(env
.local(), derived_instance->FindInstanceInPrototypeChain( derived
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1421, "Check failed: %s.", "derived_instance->Equals(env.local(), derived_instance->FindInstanceInPrototypeChain( derived)) .FromJust()"
); } } while (0)
;
1422 CHECK(derived_instance->FindInstanceInPrototypeChain(other).IsEmpty())do { if ((__builtin_expect(!!(!(derived_instance->FindInstanceInPrototypeChain
(other).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1422, "Check failed: %s.", "derived_instance->FindInstanceInPrototypeChain(other).IsEmpty()"
); } } while (0)
;
1423
1424 // other_instance is an instance of other and its immediate
1425 // prototype derived_instance2 is an instance of base and derived.
1426 // Note, derived_instance is an instance of base and derived too,
1427 // but it comes after derived_instance2 in the prototype chain of
1428 // other_instance.
1429 CHECK(derived_instance2->Equals(do { if ((__builtin_expect(!!(!(derived_instance2->Equals(
env.local(), other_instance->FindInstanceInPrototypeChain
(base)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1432, "Check failed: %s.", "derived_instance2->Equals( env.local(), other_instance->FindInstanceInPrototypeChain(base)) .FromJust()"
); } } while (0)
1430 env.local(),do { if ((__builtin_expect(!!(!(derived_instance2->Equals(
env.local(), other_instance->FindInstanceInPrototypeChain
(base)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1432, "Check failed: %s.", "derived_instance2->Equals( env.local(), other_instance->FindInstanceInPrototypeChain(base)) .FromJust()"
); } } while (0)
1431 other_instance->FindInstanceInPrototypeChain(base))do { if ((__builtin_expect(!!(!(derived_instance2->Equals(
env.local(), other_instance->FindInstanceInPrototypeChain
(base)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1432, "Check failed: %s.", "derived_instance2->Equals( env.local(), other_instance->FindInstanceInPrototypeChain(base)) .FromJust()"
); } } while (0)
1432 .FromJust())do { if ((__builtin_expect(!!(!(derived_instance2->Equals(
env.local(), other_instance->FindInstanceInPrototypeChain
(base)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1432, "Check failed: %s.", "derived_instance2->Equals( env.local(), other_instance->FindInstanceInPrototypeChain(base)) .FromJust()"
); } } while (0)
;
1433 CHECK(derived_instance2->Equals(env.local(),do { if ((__builtin_expect(!!(!(derived_instance2->Equals(
env.local(), other_instance->FindInstanceInPrototypeChain(
derived)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1436, "Check failed: %s.", "derived_instance2->Equals(env.local(), other_instance->FindInstanceInPrototypeChain( derived)) .FromJust()"
); } } while (0)
1434 other_instance->FindInstanceInPrototypeChain(do { if ((__builtin_expect(!!(!(derived_instance2->Equals(
env.local(), other_instance->FindInstanceInPrototypeChain(
derived)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1436, "Check failed: %s.", "derived_instance2->Equals(env.local(), other_instance->FindInstanceInPrototypeChain( derived)) .FromJust()"
); } } while (0)
1435 derived))do { if ((__builtin_expect(!!(!(derived_instance2->Equals(
env.local(), other_instance->FindInstanceInPrototypeChain(
derived)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1436, "Check failed: %s.", "derived_instance2->Equals(env.local(), other_instance->FindInstanceInPrototypeChain( derived)) .FromJust()"
); } } while (0)
1436 .FromJust())do { if ((__builtin_expect(!!(!(derived_instance2->Equals(
env.local(), other_instance->FindInstanceInPrototypeChain(
derived)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1436, "Check failed: %s.", "derived_instance2->Equals(env.local(), other_instance->FindInstanceInPrototypeChain( derived)) .FromJust()"
); } } while (0)
;
1437 CHECK(other_instance->Equals(do { if ((__builtin_expect(!!(!(other_instance->Equals( env
.local(), other_instance->FindInstanceInPrototypeChain(other
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1440, "Check failed: %s.", "other_instance->Equals( env.local(), other_instance->FindInstanceInPrototypeChain(other)) .FromJust()"
); } } while (0)
1438 env.local(),do { if ((__builtin_expect(!!(!(other_instance->Equals( env
.local(), other_instance->FindInstanceInPrototypeChain(other
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1440, "Check failed: %s.", "other_instance->Equals( env.local(), other_instance->FindInstanceInPrototypeChain(other)) .FromJust()"
); } } while (0)
1439 other_instance->FindInstanceInPrototypeChain(other))do { if ((__builtin_expect(!!(!(other_instance->Equals( env
.local(), other_instance->FindInstanceInPrototypeChain(other
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1440, "Check failed: %s.", "other_instance->Equals( env.local(), other_instance->FindInstanceInPrototypeChain(other)) .FromJust()"
); } } while (0)
1440 .FromJust())do { if ((__builtin_expect(!!(!(other_instance->Equals( env
.local(), other_instance->FindInstanceInPrototypeChain(other
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1440, "Check failed: %s.", "other_instance->Equals( env.local(), other_instance->FindInstanceInPrototypeChain(other)) .FromJust()"
); } } while (0)
;
1441}
1442
1443
1444THREADED_TEST(TinyInteger)static void TestTinyInteger(); RegisterThreadedTest register_TinyInteger
(TestTinyInteger, "TinyInteger"); static void TestTinyInteger
(); CcTest register_test_TinyInteger(TestTinyInteger, "../test/cctest/test-api.cc"
, "TinyInteger", __null, true, true); static void TestTinyInteger
()
{
1445 LocalContext env;
1446 v8::Isolate* isolate = env->GetIsolate();
1447 v8::HandleScope scope(isolate);
1448
1449 int32_t value = 239;
1450 Local<v8::Integer> value_obj = v8::Integer::New(isolate, value);
1451 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1451, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1452
1453 value_obj = v8::Integer::New(isolate, value);
1454 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1454, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1455}
1456
1457
1458THREADED_TEST(BigSmiInteger)static void TestBigSmiInteger(); RegisterThreadedTest register_BigSmiInteger
(TestBigSmiInteger, "BigSmiInteger"); static void TestBigSmiInteger
(); CcTest register_test_BigSmiInteger(TestBigSmiInteger, "../test/cctest/test-api.cc"
, "BigSmiInteger", __null, true, true); static void TestBigSmiInteger
()
{
1459 LocalContext env;
1460 v8::HandleScope scope(env->GetIsolate());
1461 v8::Isolate* isolate = CcTest::isolate();
1462
1463 int32_t value = i::Smi::kMaxValue;
1464 // We cannot add one to a Smi::kMaxValue without wrapping.
1465 if (i::SmiValuesAre31Bits()) {
1466 CHECK(i::Smi::IsValid(value))do { if ((__builtin_expect(!!(!(i::Smi::IsValid(value))), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 1466, "Check failed: %s."
, "i::Smi::IsValid(value)"); } } while (0)
;
1467 CHECK(!i::Smi::IsValid(value + 1))do { if ((__builtin_expect(!!(!(!i::Smi::IsValid(value + 1)))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 1467, "Check failed: %s."
, "!i::Smi::IsValid(value + 1)"); } } while (0)
;
1468
1469 Local<v8::Integer> value_obj = v8::Integer::New(isolate, value);
1470 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1470, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1471
1472 value_obj = v8::Integer::New(isolate, value);
1473 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1473, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1474 }
1475}
1476
1477
1478THREADED_TEST(BigInteger)static void TestBigInteger(); RegisterThreadedTest register_BigInteger
(TestBigInteger, "BigInteger"); static void TestBigInteger();
CcTest register_test_BigInteger(TestBigInteger, "../test/cctest/test-api.cc"
, "BigInteger", __null, true, true); static void TestBigInteger
()
{
1479 LocalContext env;
1480 v8::HandleScope scope(env->GetIsolate());
1481 v8::Isolate* isolate = CcTest::isolate();
1482
1483 // We cannot add one to a Smi::kMaxValue without wrapping.
1484 if (i::SmiValuesAre31Bits()) {
1485 // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1.
1486 // The code will not be run in that case, due to the "if" guard.
1487 int32_t value =
1488 static_cast<int32_t>(static_cast<uint32_t>(i::Smi::kMaxValue) + 1);
1489 CHECK(value > i::Smi::kMaxValue)do { if ((__builtin_expect(!!(!(value > i::Smi::kMaxValue)
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1489, "Check failed: %s."
, "value > i::Smi::kMaxValue"); } } while (0)
;
1490 CHECK(!i::Smi::IsValid(value))do { if ((__builtin_expect(!!(!(!i::Smi::IsValid(value))), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1490, "Check failed: %s."
, "!i::Smi::IsValid(value)"); } } while (0)
;
1491
1492 Local<v8::Integer> value_obj = v8::Integer::New(isolate, value);
1493 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1493, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1494
1495 value_obj = v8::Integer::New(isolate, value);
1496 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1496, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1497 }
1498}
1499
1500
1501THREADED_TEST(TinyUnsignedInteger)static void TestTinyUnsignedInteger(); RegisterThreadedTest register_TinyUnsignedInteger
(TestTinyUnsignedInteger, "TinyUnsignedInteger"); static void
TestTinyUnsignedInteger(); CcTest register_test_TinyUnsignedInteger
(TestTinyUnsignedInteger, "../test/cctest/test-api.cc", "TinyUnsignedInteger"
, __null, true, true); static void TestTinyUnsignedInteger()
{
1502 LocalContext env;
1503 v8::HandleScope scope(env->GetIsolate());
1504 v8::Isolate* isolate = CcTest::isolate();
1505
1506 uint32_t value = 239;
1507
1508 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(isolate, value);
1509 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1509, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1510
1511 value_obj = v8::Integer::NewFromUnsigned(isolate, value);
1512 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1512, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1513}
1514
1515
1516THREADED_TEST(BigUnsignedSmiInteger)static void TestBigUnsignedSmiInteger(); RegisterThreadedTest
register_BigUnsignedSmiInteger(TestBigUnsignedSmiInteger, "BigUnsignedSmiInteger"
); static void TestBigUnsignedSmiInteger(); CcTest register_test_BigUnsignedSmiInteger
(TestBigUnsignedSmiInteger, "../test/cctest/test-api.cc", "BigUnsignedSmiInteger"
, __null, true, true); static void TestBigUnsignedSmiInteger(
)
{
1517 LocalContext env;
1518 v8::HandleScope scope(env->GetIsolate());
1519 v8::Isolate* isolate = CcTest::isolate();
1520
1521 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue);
1522 CHECK(i::Smi::IsValid(value))do { if ((__builtin_expect(!!(!(i::Smi::IsValid(value))), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 1522, "Check failed: %s."
, "i::Smi::IsValid(value)"); } } while (0)
;
1523 CHECK(!i::Smi::IsValid(value + 1))do { if ((__builtin_expect(!!(!(!i::Smi::IsValid(value + 1)))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 1523, "Check failed: %s."
, "!i::Smi::IsValid(value + 1)"); } } while (0)
;
1524
1525 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(isolate, value);
1526 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1526, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1527
1528 value_obj = v8::Integer::NewFromUnsigned(isolate, value);
1529 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1529, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1530}
1531
1532
1533THREADED_TEST(BigUnsignedInteger)static void TestBigUnsignedInteger(); RegisterThreadedTest register_BigUnsignedInteger
(TestBigUnsignedInteger, "BigUnsignedInteger"); static void TestBigUnsignedInteger
(); CcTest register_test_BigUnsignedInteger(TestBigUnsignedInteger
, "../test/cctest/test-api.cc", "BigUnsignedInteger", __null,
true, true); static void TestBigUnsignedInteger()
{
1534 LocalContext env;
1535 v8::HandleScope scope(env->GetIsolate());
1536 v8::Isolate* isolate = CcTest::isolate();
1537
1538 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1;
1539 CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue))do { if ((__builtin_expect(!!(!(value > static_cast<uint32_t
>(i::Smi::kMaxValue))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1539, "Check failed: %s.", "value > static_cast<uint32_t>(i::Smi::kMaxValue)"
); } } while (0)
;
1540 CHECK(!i::Smi::IsValid(value))do { if ((__builtin_expect(!!(!(!i::Smi::IsValid(value))), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1540, "Check failed: %s."
, "!i::Smi::IsValid(value)"); } } while (0)
;
1541
1542 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(isolate, value);
1543 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1543, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1544
1545 value_obj = v8::Integer::NewFromUnsigned(isolate, value);
1546 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1546, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1547}
1548
1549
1550THREADED_TEST(OutOfSignedRangeUnsignedInteger)static void TestOutOfSignedRangeUnsignedInteger(); RegisterThreadedTest
register_OutOfSignedRangeUnsignedInteger(TestOutOfSignedRangeUnsignedInteger
, "OutOfSignedRangeUnsignedInteger"); static void TestOutOfSignedRangeUnsignedInteger
(); CcTest register_test_OutOfSignedRangeUnsignedInteger(TestOutOfSignedRangeUnsignedInteger
, "../test/cctest/test-api.cc", "OutOfSignedRangeUnsignedInteger"
, __null, true, true); static void TestOutOfSignedRangeUnsignedInteger
()
{
1551 LocalContext env;
1552 v8::HandleScope scope(env->GetIsolate());
1553 v8::Isolate* isolate = CcTest::isolate();
1554
1555 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1;
1556 uint32_t value = INT32_MAX_AS_UINT + 1;
1557 CHECK(value > INT32_MAX_AS_UINT)do { if ((__builtin_expect(!!(!(value > INT32_MAX_AS_UINT)
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1557, "Check failed: %s."
, "value > INT32_MAX_AS_UINT"); } } while (0)
; // No overflow.
1558
1559 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(isolate, value);
1560 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1560, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1561
1562 value_obj = v8::Integer::NewFromUnsigned(isolate, value);
1563 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(value)), (value_obj->Value()), "static_cast<int64_t>(value)"
" " "==" " " "value_obj->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1563, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1564}
1565
1566
1567THREADED_TEST(IsNativeError)static void TestIsNativeError(); RegisterThreadedTest register_IsNativeError
(TestIsNativeError, "IsNativeError"); static void TestIsNativeError
(); CcTest register_test_IsNativeError(TestIsNativeError, "../test/cctest/test-api.cc"
, "IsNativeError", __null, true, true); static void TestIsNativeError
()
{
1568 LocalContext env;
1569 v8::HandleScope scope(env->GetIsolate());
1570 v8::Local<Value> syntax_error = CompileRun(
1571 "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; ");
1572 CHECK(syntax_error->IsNativeError())do { if ((__builtin_expect(!!(!(syntax_error->IsNativeError
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1572, "Check failed: %s."
, "syntax_error->IsNativeError()"); } } while (0)
;
1573 v8::Local<Value> not_error = CompileRun("{a:42}");
1574 CHECK(!not_error->IsNativeError())do { if ((__builtin_expect(!!(!(!not_error->IsNativeError(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1574, "Check failed: %s."
, "!not_error->IsNativeError()"); } } while (0)
;
1575 v8::Local<Value> not_object = CompileRun("42");
1576 CHECK(!not_object->IsNativeError())do { if ((__builtin_expect(!!(!(!not_object->IsNativeError
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1576, "Check failed: %s."
, "!not_object->IsNativeError()"); } } while (0)
;
1577}
1578
1579
1580THREADED_TEST(IsGeneratorFunctionOrObject)static void TestIsGeneratorFunctionOrObject(); RegisterThreadedTest
register_IsGeneratorFunctionOrObject(TestIsGeneratorFunctionOrObject
, "IsGeneratorFunctionOrObject"); static void TestIsGeneratorFunctionOrObject
(); CcTest register_test_IsGeneratorFunctionOrObject(TestIsGeneratorFunctionOrObject
, "../test/cctest/test-api.cc", "IsGeneratorFunctionOrObject"
, __null, true, true); static void TestIsGeneratorFunctionOrObject
()
{
1581 LocalContext env;
1582 v8::HandleScope scope(env->GetIsolate());
1583
1584 CompileRun("function *gen() { yield 1; }\nfunction func() {}");
1585 v8::Local<Value> gen = CompileRun("gen");
1586 v8::Local<Value> genObj = CompileRun("gen()");
1587 v8::Local<Value> object = CompileRun("{a:42}");
1588 v8::Local<Value> func = CompileRun("func");
1589
1590 CHECK(gen->IsGeneratorFunction())do { if ((__builtin_expect(!!(!(gen->IsGeneratorFunction()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1590, "Check failed: %s."
, "gen->IsGeneratorFunction()"); } } while (0)
;
1591 CHECK(gen->IsFunction())do { if ((__builtin_expect(!!(!(gen->IsFunction())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1591, "Check failed: %s."
, "gen->IsFunction()"); } } while (0)
;
1592 CHECK(!gen->IsGeneratorObject())do { if ((__builtin_expect(!!(!(!gen->IsGeneratorObject())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1592, "Check failed: %s."
, "!gen->IsGeneratorObject()"); } } while (0)
;
1593
1594 CHECK(!genObj->IsGeneratorFunction())do { if ((__builtin_expect(!!(!(!genObj->IsGeneratorFunction
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1594, "Check failed: %s."
, "!genObj->IsGeneratorFunction()"); } } while (0)
;
1595 CHECK(!genObj->IsFunction())do { if ((__builtin_expect(!!(!(!genObj->IsFunction())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1595, "Check failed: %s."
, "!genObj->IsFunction()"); } } while (0)
;
1596 CHECK(genObj->IsGeneratorObject())do { if ((__builtin_expect(!!(!(genObj->IsGeneratorObject(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1596, "Check failed: %s."
, "genObj->IsGeneratorObject()"); } } while (0)
;
1597
1598 CHECK(!object->IsGeneratorFunction())do { if ((__builtin_expect(!!(!(!object->IsGeneratorFunction
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1598, "Check failed: %s."
, "!object->IsGeneratorFunction()"); } } while (0)
;
1599 CHECK(!object->IsFunction())do { if ((__builtin_expect(!!(!(!object->IsFunction())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1599, "Check failed: %s."
, "!object->IsFunction()"); } } while (0)
;
1600 CHECK(!object->IsGeneratorObject())do { if ((__builtin_expect(!!(!(!object->IsGeneratorObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1600, "Check failed: %s."
, "!object->IsGeneratorObject()"); } } while (0)
;
1601
1602 CHECK(!func->IsGeneratorFunction())do { if ((__builtin_expect(!!(!(!func->IsGeneratorFunction
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1602, "Check failed: %s."
, "!func->IsGeneratorFunction()"); } } while (0)
;
1603 CHECK(func->IsFunction())do { if ((__builtin_expect(!!(!(func->IsFunction())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 1603, "Check failed: %s."
, "func->IsFunction()"); } } while (0)
;
1604 CHECK(!func->IsGeneratorObject())do { if ((__builtin_expect(!!(!(!func->IsGeneratorObject()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1604, "Check failed: %s."
, "!func->IsGeneratorObject()"); } } while (0)
;
1605}
1606
1607
1608THREADED_TEST(ArgumentsObject)static void TestArgumentsObject(); RegisterThreadedTest register_ArgumentsObject
(TestArgumentsObject, "ArgumentsObject"); static void TestArgumentsObject
(); CcTest register_test_ArgumentsObject(TestArgumentsObject,
"../test/cctest/test-api.cc", "ArgumentsObject", __null, true
, true); static void TestArgumentsObject()
{
1609 LocalContext env;
1610 v8::HandleScope scope(env->GetIsolate());
1611 v8::Local<Value> arguments_object =
1612 CompileRun("var out = 0; (function(){ out = arguments; })(1,2,3); out;");
1613 CHECK(arguments_object->IsArgumentsObject())do { if ((__builtin_expect(!!(!(arguments_object->IsArgumentsObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1613, "Check failed: %s."
, "arguments_object->IsArgumentsObject()"); } } while (0)
;
1614 v8::Local<Value> array = CompileRun("[1,2,3]");
1615 CHECK(!array->IsArgumentsObject())do { if ((__builtin_expect(!!(!(!array->IsArgumentsObject(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1615, "Check failed: %s."
, "!array->IsArgumentsObject()"); } } while (0)
;
1616 v8::Local<Value> object = CompileRun("{a:42}");
1617 CHECK(!object->IsArgumentsObject())do { if ((__builtin_expect(!!(!(!object->IsArgumentsObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1617, "Check failed: %s."
, "!object->IsArgumentsObject()"); } } while (0)
;
1618}
1619
1620
1621THREADED_TEST(IsMapOrSet)static void TestIsMapOrSet(); RegisterThreadedTest register_IsMapOrSet
(TestIsMapOrSet, "IsMapOrSet"); static void TestIsMapOrSet();
CcTest register_test_IsMapOrSet(TestIsMapOrSet, "../test/cctest/test-api.cc"
, "IsMapOrSet", __null, true, true); static void TestIsMapOrSet
()
{
1622 LocalContext env;
1623 v8::HandleScope scope(env->GetIsolate());
1624 v8::Local<Value> map = CompileRun("new Map()");
1625 v8::Local<Value> set = CompileRun("new Set()");
1626 v8::Local<Value> weak_map = CompileRun("new WeakMap()");
1627 v8::Local<Value> weak_set = CompileRun("new WeakSet()");
1628 CHECK(map->IsMap())do { if ((__builtin_expect(!!(!(map->IsMap())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1628, "Check failed: %s.", "map->IsMap()"
); } } while (0)
;
1629 CHECK(set->IsSet())do { if ((__builtin_expect(!!(!(set->IsSet())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1629, "Check failed: %s.", "set->IsSet()"
); } } while (0)
;
1630 CHECK(weak_map->IsWeakMap())do { if ((__builtin_expect(!!(!(weak_map->IsWeakMap())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1630, "Check failed: %s."
, "weak_map->IsWeakMap()"); } } while (0)
;
1631 CHECK(weak_set->IsWeakSet())do { if ((__builtin_expect(!!(!(weak_set->IsWeakSet())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1631, "Check failed: %s."
, "weak_set->IsWeakSet()"); } } while (0)
;
1632
1633 CHECK(!map->IsSet())do { if ((__builtin_expect(!!(!(!map->IsSet())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1633, "Check failed: %s.", "!map->IsSet()"
); } } while (0)
;
1634 CHECK(!map->IsWeakMap())do { if ((__builtin_expect(!!(!(!map->IsWeakMap())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1634, "Check failed: %s."
, "!map->IsWeakMap()"); } } while (0)
;
1635 CHECK(!map->IsWeakSet())do { if ((__builtin_expect(!!(!(!map->IsWeakSet())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1635, "Check failed: %s."
, "!map->IsWeakSet()"); } } while (0)
;
1636
1637 CHECK(!set->IsMap())do { if ((__builtin_expect(!!(!(!set->IsMap())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1637, "Check failed: %s.", "!set->IsMap()"
); } } while (0)
;
1638 CHECK(!set->IsWeakMap())do { if ((__builtin_expect(!!(!(!set->IsWeakMap())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1638, "Check failed: %s."
, "!set->IsWeakMap()"); } } while (0)
;
1639 CHECK(!set->IsWeakSet())do { if ((__builtin_expect(!!(!(!set->IsWeakSet())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1639, "Check failed: %s."
, "!set->IsWeakSet()"); } } while (0)
;
1640
1641 CHECK(!weak_map->IsMap())do { if ((__builtin_expect(!!(!(!weak_map->IsMap())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 1641, "Check failed: %s."
, "!weak_map->IsMap()"); } } while (0)
;
1642 CHECK(!weak_map->IsSet())do { if ((__builtin_expect(!!(!(!weak_map->IsSet())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 1642, "Check failed: %s."
, "!weak_map->IsSet()"); } } while (0)
;
1643 CHECK(!weak_map->IsWeakSet())do { if ((__builtin_expect(!!(!(!weak_map->IsWeakSet())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1643, "Check failed: %s."
, "!weak_map->IsWeakSet()"); } } while (0)
;
1644
1645 CHECK(!weak_set->IsMap())do { if ((__builtin_expect(!!(!(!weak_set->IsMap())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 1645, "Check failed: %s."
, "!weak_set->IsMap()"); } } while (0)
;
1646 CHECK(!weak_set->IsSet())do { if ((__builtin_expect(!!(!(!weak_set->IsSet())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 1646, "Check failed: %s."
, "!weak_set->IsSet()"); } } while (0)
;
1647 CHECK(!weak_set->IsWeakMap())do { if ((__builtin_expect(!!(!(!weak_set->IsWeakMap())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1647, "Check failed: %s."
, "!weak_set->IsWeakMap()"); } } while (0)
;
1648
1649 v8::Local<Value> object = CompileRun("{a:42}");
1650 CHECK(!object->IsMap())do { if ((__builtin_expect(!!(!(!object->IsMap())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1650, "Check failed: %s."
, "!object->IsMap()"); } } while (0)
;
1651 CHECK(!object->IsSet())do { if ((__builtin_expect(!!(!(!object->IsSet())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1651, "Check failed: %s."
, "!object->IsSet()"); } } while (0)
;
1652 CHECK(!object->IsWeakMap())do { if ((__builtin_expect(!!(!(!object->IsWeakMap())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1652, "Check failed: %s."
, "!object->IsWeakMap()"); } } while (0)
;
1653 CHECK(!object->IsWeakSet())do { if ((__builtin_expect(!!(!(!object->IsWeakSet())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 1653, "Check failed: %s."
, "!object->IsWeakSet()"); } } while (0)
;
1654}
1655
1656
1657THREADED_TEST(StringObject)static void TestStringObject(); RegisterThreadedTest register_StringObject
(TestStringObject, "StringObject"); static void TestStringObject
(); CcTest register_test_StringObject(TestStringObject, "../test/cctest/test-api.cc"
, "StringObject", __null, true, true); static void TestStringObject
()
{
1658 LocalContext env;
1659 v8::HandleScope scope(env->GetIsolate());
1660 v8::Local<Value> boxed_string = CompileRun("new String(\"test\")");
1661 CHECK(boxed_string->IsStringObject())do { if ((__builtin_expect(!!(!(boxed_string->IsStringObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1661, "Check failed: %s."
, "boxed_string->IsStringObject()"); } } while (0)
;
1662 v8::Local<Value> unboxed_string = CompileRun("\"test\"");
1663 CHECK(!unboxed_string->IsStringObject())do { if ((__builtin_expect(!!(!(!unboxed_string->IsStringObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1663, "Check failed: %s."
, "!unboxed_string->IsStringObject()"); } } while (0)
;
1664 v8::Local<Value> boxed_not_string = CompileRun("new Number(42)");
1665 CHECK(!boxed_not_string->IsStringObject())do { if ((__builtin_expect(!!(!(!boxed_not_string->IsStringObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1665, "Check failed: %s."
, "!boxed_not_string->IsStringObject()"); } } while (0)
;
1666 v8::Local<Value> not_object = CompileRun("0");
1667 CHECK(!not_object->IsStringObject())do { if ((__builtin_expect(!!(!(!not_object->IsStringObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1667, "Check failed: %s."
, "!not_object->IsStringObject()"); } } while (0)
;
1668 v8::Local<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>();
1669 CHECK(!as_boxed.IsEmpty())do { if ((__builtin_expect(!!(!(!as_boxed.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1669, "Check failed: %s."
, "!as_boxed.IsEmpty()"); } } while (0)
;
1670 Local<v8::String> the_string = as_boxed->ValueOf();
1671 CHECK(!the_string.IsEmpty())do { if ((__builtin_expect(!!(!(!the_string.IsEmpty())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 1671, "Check failed: %s."
, "!the_string.IsEmpty()"); } } while (0)
;
1672 ExpectObject("\"test\"", the_string);
1673 v8::Local<v8::Value> new_boxed_string = v8::StringObject::New(the_string);
1674 CHECK(new_boxed_string->IsStringObject())do { if ((__builtin_expect(!!(!(new_boxed_string->IsStringObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1674, "Check failed: %s."
, "new_boxed_string->IsStringObject()"); } } while (0)
;
1675 as_boxed = new_boxed_string.As<v8::StringObject>();
1676 the_string = as_boxed->ValueOf();
1677 CHECK(!the_string.IsEmpty())do { if ((__builtin_expect(!!(!(!the_string.IsEmpty())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 1677, "Check failed: %s."
, "!the_string.IsEmpty()"); } } while (0)
;
1678 ExpectObject("\"test\"", the_string);
1679}
1680
1681
1682TEST(StringObjectDelete)static void TestStringObjectDelete(); CcTest register_test_StringObjectDelete
(TestStringObjectDelete, "../test/cctest/test-api.cc", "StringObjectDelete"
, __null, true, true); static void TestStringObjectDelete()
{
1683 LocalContext context;
1684 v8::HandleScope scope(context->GetIsolate());
1685 v8::Local<Value> boxed_string = CompileRun("new String(\"test\")");
1686 CHECK(boxed_string->IsStringObject())do { if ((__builtin_expect(!!(!(boxed_string->IsStringObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1686, "Check failed: %s."
, "boxed_string->IsStringObject()"); } } while (0)
;
1687 v8::Local<v8::Object> str_obj = boxed_string.As<v8::Object>();
1688 CHECK(!str_obj->Delete(context.local(), 2).FromJust())do { if ((__builtin_expect(!!(!(!str_obj->Delete(context.local
(), 2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1688, "Check failed: %s.", "!str_obj->Delete(context.local(), 2).FromJust()"
); } } while (0)
;
1689 CHECK(!str_obj->Delete(context.local(), v8_num(2)).FromJust())do { if ((__builtin_expect(!!(!(!str_obj->Delete(context.local
(), v8_num(2)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1689, "Check failed: %s.", "!str_obj->Delete(context.local(), v8_num(2)).FromJust()"
); } } while (0)
;
1690}
1691
1692
1693THREADED_TEST(NumberObject)static void TestNumberObject(); RegisterThreadedTest register_NumberObject
(TestNumberObject, "NumberObject"); static void TestNumberObject
(); CcTest register_test_NumberObject(TestNumberObject, "../test/cctest/test-api.cc"
, "NumberObject", __null, true, true); static void TestNumberObject
()
{
1694 LocalContext env;
1695 v8::HandleScope scope(env->GetIsolate());
1696 v8::Local<Value> boxed_number = CompileRun("new Number(42)");
1697 CHECK(boxed_number->IsNumberObject())do { if ((__builtin_expect(!!(!(boxed_number->IsNumberObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1697, "Check failed: %s."
, "boxed_number->IsNumberObject()"); } } while (0)
;
1698 v8::Local<Value> unboxed_number = CompileRun("42");
1699 CHECK(!unboxed_number->IsNumberObject())do { if ((__builtin_expect(!!(!(!unboxed_number->IsNumberObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1699, "Check failed: %s."
, "!unboxed_number->IsNumberObject()"); } } while (0)
;
1700 v8::Local<Value> boxed_not_number = CompileRun("new Boolean(false)");
1701 CHECK(!boxed_not_number->IsNumberObject())do { if ((__builtin_expect(!!(!(!boxed_not_number->IsNumberObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1701, "Check failed: %s."
, "!boxed_not_number->IsNumberObject()"); } } while (0)
;
1702 v8::Local<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>();
1703 CHECK(!as_boxed.IsEmpty())do { if ((__builtin_expect(!!(!(!as_boxed.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1703, "Check failed: %s."
, "!as_boxed.IsEmpty()"); } } while (0)
;
1704 double the_number = as_boxed->ValueOf();
1705 CHECK_EQ(42.0, the_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(the_number), "42.0" " " "==" " " "the_number")) { V8_Fatal(
"../test/cctest/test-api.cc", 1705, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
1706 v8::Local<v8::Value> new_boxed_number =
1707 v8::NumberObject::New(env->GetIsolate(), 43);
1708 CHECK(new_boxed_number->IsNumberObject())do { if ((__builtin_expect(!!(!(new_boxed_number->IsNumberObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1708, "Check failed: %s."
, "new_boxed_number->IsNumberObject()"); } } while (0)
;
1709 as_boxed = new_boxed_number.As<v8::NumberObject>();
1710 the_number = as_boxed->ValueOf();
1711 CHECK_EQ(43.0, the_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (43.0),
(the_number), "43.0" " " "==" " " "the_number")) { V8_Fatal(
"../test/cctest/test-api.cc", 1711, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
1712}
1713
1714
1715THREADED_TEST(BooleanObject)static void TestBooleanObject(); RegisterThreadedTest register_BooleanObject
(TestBooleanObject, "BooleanObject"); static void TestBooleanObject
(); CcTest register_test_BooleanObject(TestBooleanObject, "../test/cctest/test-api.cc"
, "BooleanObject", __null, true, true); static void TestBooleanObject
()
{
1716 LocalContext env;
1717 v8::HandleScope scope(env->GetIsolate());
1718 v8::Local<Value> boxed_boolean = CompileRun("new Boolean(true)");
1719 CHECK(boxed_boolean->IsBooleanObject())do { if ((__builtin_expect(!!(!(boxed_boolean->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1719, "Check failed: %s."
, "boxed_boolean->IsBooleanObject()"); } } while (0)
;
1720 v8::Local<Value> unboxed_boolean = CompileRun("true");
1721 CHECK(!unboxed_boolean->IsBooleanObject())do { if ((__builtin_expect(!!(!(!unboxed_boolean->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1721, "Check failed: %s."
, "!unboxed_boolean->IsBooleanObject()"); } } while (0)
;
1722 v8::Local<Value> boxed_not_boolean = CompileRun("new Number(42)");
1723 CHECK(!boxed_not_boolean->IsBooleanObject())do { if ((__builtin_expect(!!(!(!boxed_not_boolean->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1723, "Check failed: %s."
, "!boxed_not_boolean->IsBooleanObject()"); } } while (0)
;
1724 v8::Local<v8::BooleanObject> as_boxed = boxed_boolean.As<v8::BooleanObject>();
1725 CHECK(!as_boxed.IsEmpty())do { if ((__builtin_expect(!!(!(!as_boxed.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 1725, "Check failed: %s."
, "!as_boxed.IsEmpty()"); } } while (0)
;
1726 bool the_boolean = as_boxed->ValueOf();
1727 CHECK_EQ(true, the_boolean)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (true),
(the_boolean), "true" " " "==" " " "the_boolean")) { V8_Fatal
("../test/cctest/test-api.cc", 1727, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
1728 v8::Local<v8::Value> boxed_true =
1729 v8::BooleanObject::New(env->GetIsolate(), true);
1730 v8::Local<v8::Value> boxed_false =
1731 v8::BooleanObject::New(env->GetIsolate(), false);
1732 CHECK(boxed_true->IsBooleanObject())do { if ((__builtin_expect(!!(!(boxed_true->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1732, "Check failed: %s."
, "boxed_true->IsBooleanObject()"); } } while (0)
;
1733 CHECK(boxed_false->IsBooleanObject())do { if ((__builtin_expect(!!(!(boxed_false->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1733, "Check failed: %s."
, "boxed_false->IsBooleanObject()"); } } while (0)
;
1734 as_boxed = boxed_true.As<v8::BooleanObject>();
1735 CHECK_EQ(true, as_boxed->ValueOf())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (true),
(as_boxed->ValueOf()), "true" " " "==" " " "as_boxed->ValueOf()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1735, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1736 as_boxed = boxed_false.As<v8::BooleanObject>();
1737 CHECK_EQ(false, as_boxed->ValueOf())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (as_boxed->ValueOf()), "false" " " "==" " " "as_boxed->ValueOf()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1737, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1738}
1739
1740
1741THREADED_TEST(PrimitiveAndWrappedBooleans)static void TestPrimitiveAndWrappedBooleans(); RegisterThreadedTest
register_PrimitiveAndWrappedBooleans(TestPrimitiveAndWrappedBooleans
, "PrimitiveAndWrappedBooleans"); static void TestPrimitiveAndWrappedBooleans
(); CcTest register_test_PrimitiveAndWrappedBooleans(TestPrimitiveAndWrappedBooleans
, "../test/cctest/test-api.cc", "PrimitiveAndWrappedBooleans"
, __null, true, true); static void TestPrimitiveAndWrappedBooleans
()
{
1742 LocalContext env;
1743 v8::HandleScope scope(env->GetIsolate());
1744
1745 Local<Value> primitive_false = Boolean::New(env->GetIsolate(), false);
1746 CHECK(primitive_false->IsBoolean())do { if ((__builtin_expect(!!(!(primitive_false->IsBoolean
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1746, "Check failed: %s."
, "primitive_false->IsBoolean()"); } } while (0)
;
1747 CHECK(!primitive_false->IsBooleanObject())do { if ((__builtin_expect(!!(!(!primitive_false->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1747, "Check failed: %s."
, "!primitive_false->IsBooleanObject()"); } } while (0)
;
1748 CHECK(!primitive_false->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(!primitive_false->BooleanValue
(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1748, "Check failed: %s.", "!primitive_false->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1749 CHECK(!primitive_false->IsTrue())do { if ((__builtin_expect(!!(!(!primitive_false->IsTrue()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1749, "Check failed: %s."
, "!primitive_false->IsTrue()"); } } while (0)
;
1750 CHECK(primitive_false->IsFalse())do { if ((__builtin_expect(!!(!(primitive_false->IsFalse()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1750, "Check failed: %s."
, "primitive_false->IsFalse()"); } } while (0)
;
1751
1752 Local<Value> false_value = BooleanObject::New(env->GetIsolate(), false);
1753 CHECK(!false_value->IsBoolean())do { if ((__builtin_expect(!!(!(!false_value->IsBoolean())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1753, "Check failed: %s."
, "!false_value->IsBoolean()"); } } while (0)
;
1754 CHECK(false_value->IsBooleanObject())do { if ((__builtin_expect(!!(!(false_value->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1754, "Check failed: %s."
, "false_value->IsBooleanObject()"); } } while (0)
;
1755 CHECK(false_value->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(false_value->BooleanValue(
env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1755, "Check failed: %s.", "false_value->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1756 CHECK(!false_value->IsTrue())do { if ((__builtin_expect(!!(!(!false_value->IsTrue())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1756, "Check failed: %s."
, "!false_value->IsTrue()"); } } while (0)
;
1757 CHECK(!false_value->IsFalse())do { if ((__builtin_expect(!!(!(!false_value->IsFalse())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 1757, "Check failed: %s."
, "!false_value->IsFalse()"); } } while (0)
;
1758
1759 Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>();
1760 CHECK(!false_boolean_object->IsBoolean())do { if ((__builtin_expect(!!(!(!false_boolean_object->IsBoolean
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1760, "Check failed: %s."
, "!false_boolean_object->IsBoolean()"); } } while (0)
;
1761 CHECK(false_boolean_object->IsBooleanObject())do { if ((__builtin_expect(!!(!(false_boolean_object->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1761, "Check failed: %s."
, "false_boolean_object->IsBooleanObject()"); } } while (0
)
;
1762 CHECK(false_boolean_object->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(false_boolean_object->BooleanValue
(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1762, "Check failed: %s.", "false_boolean_object->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1763 CHECK(!false_boolean_object->ValueOf())do { if ((__builtin_expect(!!(!(!false_boolean_object->ValueOf
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1763, "Check failed: %s."
, "!false_boolean_object->ValueOf()"); } } while (0)
;
1764 CHECK(!false_boolean_object->IsTrue())do { if ((__builtin_expect(!!(!(!false_boolean_object->IsTrue
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1764, "Check failed: %s."
, "!false_boolean_object->IsTrue()"); } } while (0)
;
1765 CHECK(!false_boolean_object->IsFalse())do { if ((__builtin_expect(!!(!(!false_boolean_object->IsFalse
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1765, "Check failed: %s."
, "!false_boolean_object->IsFalse()"); } } while (0)
;
1766
1767 Local<Value> primitive_true = Boolean::New(env->GetIsolate(), true);
1768 CHECK(primitive_true->IsBoolean())do { if ((__builtin_expect(!!(!(primitive_true->IsBoolean(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1768, "Check failed: %s."
, "primitive_true->IsBoolean()"); } } while (0)
;
1769 CHECK(!primitive_true->IsBooleanObject())do { if ((__builtin_expect(!!(!(!primitive_true->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1769, "Check failed: %s."
, "!primitive_true->IsBooleanObject()"); } } while (0)
;
1770 CHECK(primitive_true->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(primitive_true->BooleanValue
(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1770, "Check failed: %s.", "primitive_true->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1771 CHECK(primitive_true->IsTrue())do { if ((__builtin_expect(!!(!(primitive_true->IsTrue()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 1771, "Check failed: %s."
, "primitive_true->IsTrue()"); } } while (0)
;
1772 CHECK(!primitive_true->IsFalse())do { if ((__builtin_expect(!!(!(!primitive_true->IsFalse()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1772, "Check failed: %s."
, "!primitive_true->IsFalse()"); } } while (0)
;
1773
1774 Local<Value> true_value = BooleanObject::New(env->GetIsolate(), true);
1775 CHECK(!true_value->IsBoolean())do { if ((__builtin_expect(!!(!(!true_value->IsBoolean()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 1775, "Check failed: %s."
, "!true_value->IsBoolean()"); } } while (0)
;
1776 CHECK(true_value->IsBooleanObject())do { if ((__builtin_expect(!!(!(true_value->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1776, "Check failed: %s."
, "true_value->IsBooleanObject()"); } } while (0)
;
1777 CHECK(true_value->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(true_value->BooleanValue(env
.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1777, "Check failed: %s.", "true_value->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1778 CHECK(!true_value->IsTrue())do { if ((__builtin_expect(!!(!(!true_value->IsTrue())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1778, "Check failed: %s."
, "!true_value->IsTrue()"); } } while (0)
;
1779 CHECK(!true_value->IsFalse())do { if ((__builtin_expect(!!(!(!true_value->IsFalse())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 1779, "Check failed: %s."
, "!true_value->IsFalse()"); } } while (0)
;
1780
1781 Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>();
1782 CHECK(!true_boolean_object->IsBoolean())do { if ((__builtin_expect(!!(!(!true_boolean_object->IsBoolean
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1782, "Check failed: %s."
, "!true_boolean_object->IsBoolean()"); } } while (0)
;
1783 CHECK(true_boolean_object->IsBooleanObject())do { if ((__builtin_expect(!!(!(true_boolean_object->IsBooleanObject
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1783, "Check failed: %s."
, "true_boolean_object->IsBooleanObject()"); } } while (0)
;
1784 CHECK(true_boolean_object->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(true_boolean_object->BooleanValue
(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1784, "Check failed: %s.", "true_boolean_object->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1785 CHECK(true_boolean_object->ValueOf())do { if ((__builtin_expect(!!(!(true_boolean_object->ValueOf
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1785, "Check failed: %s."
, "true_boolean_object->ValueOf()"); } } while (0)
;
1786 CHECK(!true_boolean_object->IsTrue())do { if ((__builtin_expect(!!(!(!true_boolean_object->IsTrue
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1786, "Check failed: %s."
, "!true_boolean_object->IsTrue()"); } } while (0)
;
1787 CHECK(!true_boolean_object->IsFalse())do { if ((__builtin_expect(!!(!(!true_boolean_object->IsFalse
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1787, "Check failed: %s."
, "!true_boolean_object->IsFalse()"); } } while (0)
;
1788}
1789
1790
1791THREADED_TEST(Number)static void TestNumber(); RegisterThreadedTest register_Number
(TestNumber, "Number"); static void TestNumber(); CcTest register_test_Number
(TestNumber, "../test/cctest/test-api.cc", "Number", __null, true
, true); static void TestNumber()
{
1792 LocalContext env;
1793 v8::HandleScope scope(env->GetIsolate());
1794 double PI = 3.1415926;
1795 Local<v8::Number> pi_obj = v8::Number::New(env->GetIsolate(), PI);
1796 CHECK_EQ(PI, pi_obj->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (PI), (
pi_obj->NumberValue(env.local()).FromJust()), "PI" " " "=="
" " "pi_obj->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 1796, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
1797}
1798
1799
1800THREADED_TEST(ToNumber)static void TestToNumber(); RegisterThreadedTest register_ToNumber
(TestToNumber, "ToNumber"); static void TestToNumber(); CcTest
register_test_ToNumber(TestToNumber, "../test/cctest/test-api.cc"
, "ToNumber", __null, true, true); static void TestToNumber()
{
1801 LocalContext env;
1802 v8::Isolate* isolate = CcTest::isolate();
1803 v8::HandleScope scope(isolate);
1804 Local<String> str = v8_str("3.1415926");
1805 CHECK_EQ(3.1415926, str->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.1415926
), (str->NumberValue(env.local()).FromJust()), "3.1415926"
" " "==" " " "str->NumberValue(env.local()).FromJust()"))
{ V8_Fatal("../test/cctest/test-api.cc", 1805, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1806 v8::Local<v8::Boolean> t = v8::True(isolate);
1807 CHECK_EQ(1.0, t->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.0), (
t->NumberValue(env.local()).FromJust()), "1.0" " " "==" " "
"t->NumberValue(env.local()).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1807, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1808 v8::Local<v8::Boolean> f = v8::False(isolate);
1809 CHECK_EQ(0.0, f->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0.0), (
f->NumberValue(env.local()).FromJust()), "0.0" " " "==" " "
"f->NumberValue(env.local()).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 1809, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
1810}
1811
1812
1813THREADED_TEST(Date)static void TestDate(); RegisterThreadedTest register_Date(TestDate
, "Date"); static void TestDate(); CcTest register_test_Date(
TestDate, "../test/cctest/test-api.cc", "Date", __null, true,
true); static void TestDate()
{
1814 LocalContext env;
1815 v8::HandleScope scope(env->GetIsolate());
1816 double PI = 3.1415926;
1817 Local<Value> date = v8::Date::New(env.local(), PI).ToLocalChecked();
1818 CHECK_EQ(3.0, date->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.0), (
date->NumberValue(env.local()).FromJust()), "3.0" " " "=="
" " "date->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 1818, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
1819 CHECK(date.As<v8::Date>()do { if ((__builtin_expect(!!(!(date.As<v8::Date>() ->
Set(env.local(), v8_str("property"), v8::Integer::New(env->
GetIsolate(), 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1822, "Check failed: %s.", "date.As<v8::Date>() ->Set(env.local(), v8_str(\"property\"), v8::Integer::New(env->GetIsolate(), 42)) .FromJust()"
); } } while (0)
1820 ->Set(env.local(), v8_str("property"),do { if ((__builtin_expect(!!(!(date.As<v8::Date>() ->
Set(env.local(), v8_str("property"), v8::Integer::New(env->
GetIsolate(), 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1822, "Check failed: %s.", "date.As<v8::Date>() ->Set(env.local(), v8_str(\"property\"), v8::Integer::New(env->GetIsolate(), 42)) .FromJust()"
); } } while (0)
1821 v8::Integer::New(env->GetIsolate(), 42))do { if ((__builtin_expect(!!(!(date.As<v8::Date>() ->
Set(env.local(), v8_str("property"), v8::Integer::New(env->
GetIsolate(), 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1822, "Check failed: %s.", "date.As<v8::Date>() ->Set(env.local(), v8_str(\"property\"), v8::Integer::New(env->GetIsolate(), 42)) .FromJust()"
); } } while (0)
1822 .FromJust())do { if ((__builtin_expect(!!(!(date.As<v8::Date>() ->
Set(env.local(), v8_str("property"), v8::Integer::New(env->
GetIsolate(), 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1822, "Check failed: %s.", "date.As<v8::Date>() ->Set(env.local(), v8_str(\"property\"), v8::Integer::New(env->GetIsolate(), 42)) .FromJust()"
); } } while (0)
;
1823 CHECK_EQ(42, date.As<v8::Date>()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
date.As<v8::Date>() ->Get(env.local(), v8_str("property"
)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()
), "42" " " "==" " " "date.As<v8::Date>() ->Get(env.local(), v8_str(\"property\")) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
1824 ->Get(env.local(), v8_str("property"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
date.As<v8::Date>() ->Get(env.local(), v8_str("property"
)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()
), "42" " " "==" " " "date.As<v8::Date>() ->Get(env.local(), v8_str(\"property\")) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
1825 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
date.As<v8::Date>() ->Get(env.local(), v8_str("property"
)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()
), "42" " " "==" " " "date.As<v8::Date>() ->Get(env.local(), v8_str(\"property\")) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
1826 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
date.As<v8::Date>() ->Get(env.local(), v8_str("property"
)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()
), "42" " " "==" " " "date.As<v8::Date>() ->Get(env.local(), v8_str(\"property\")) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
1827 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
date.As<v8::Date>() ->Get(env.local(), v8_str("property"
)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()
), "42" " " "==" " " "date.As<v8::Date>() ->Get(env.local(), v8_str(\"property\")) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1828}
1829
1830
1831THREADED_TEST(Boolean)static void TestBoolean(); RegisterThreadedTest register_Boolean
(TestBoolean, "Boolean"); static void TestBoolean(); CcTest register_test_Boolean
(TestBoolean, "../test/cctest/test-api.cc", "Boolean", __null
, true, true); static void TestBoolean()
{
1832 LocalContext env;
1833 v8::Isolate* isolate = env->GetIsolate();
1834 v8::HandleScope scope(isolate);
1835 v8::Local<v8::Boolean> t = v8::True(isolate);
1836 CHECK(t->Value())do { if ((__builtin_expect(!!(!(t->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1836, "Check failed: %s.", "t->Value()"
); } } while (0)
;
1837 v8::Local<v8::Boolean> f = v8::False(isolate);
1838 CHECK(!f->Value())do { if ((__builtin_expect(!!(!(!f->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1838, "Check failed: %s.", "!f->Value()"
); } } while (0)
;
1839 v8::Local<v8::Primitive> u = v8::Undefined(isolate);
1840 CHECK(!u->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(!u->BooleanValue(env.local
()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1840, "Check failed: %s.", "!u->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1841 v8::Local<v8::Primitive> n = v8::Null(isolate);
1842 CHECK(!n->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(!n->BooleanValue(env.local
()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1842, "Check failed: %s.", "!n->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1843 v8::Local<String> str1 = v8_str("");
1844 CHECK(!str1->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(!str1->BooleanValue(env.local
()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1844, "Check failed: %s.", "!str1->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1845 v8::Local<String> str2 = v8_str("x");
1846 CHECK(str2->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(str2->BooleanValue(env.local
()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1846, "Check failed: %s.", "str2->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1847 CHECK(!v8::Number::New(isolate, 0)->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(!v8::Number::New(isolate, 0)->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1847, "Check failed: %s.", "!v8::Number::New(isolate, 0)->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1848 CHECK(v8::Number::New(isolate, -1)->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(v8::Number::New(isolate, -1)->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1848, "Check failed: %s.", "v8::Number::New(isolate, -1)->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1849 CHECK(v8::Number::New(isolate, 1)->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(v8::Number::New(isolate, 1)->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1849, "Check failed: %s.", "v8::Number::New(isolate, 1)->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1850 CHECK(v8::Number::New(isolate, 42)->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(v8::Number::New(isolate, 42)->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1850, "Check failed: %s.", "v8::Number::New(isolate, 42)->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1851 CHECK(!v8_compile("NaN")do { if ((__builtin_expect(!!(!(!v8_compile("NaN") ->Run(env
.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1855, "Check failed: %s."
, "!v8_compile(\"NaN\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1852 ->Run(env.local())do { if ((__builtin_expect(!!(!(!v8_compile("NaN") ->Run(env
.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1855, "Check failed: %s."
, "!v8_compile(\"NaN\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1853 .ToLocalChecked()do { if ((__builtin_expect(!!(!(!v8_compile("NaN") ->Run(env
.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1855, "Check failed: %s."
, "!v8_compile(\"NaN\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1854 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(!v8_compile("NaN") ->Run(env
.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1855, "Check failed: %s."
, "!v8_compile(\"NaN\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1855 .FromJust())do { if ((__builtin_expect(!!(!(!v8_compile("NaN") ->Run(env
.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1855, "Check failed: %s."
, "!v8_compile(\"NaN\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
1856}
1857
1858
1859static void DummyCallHandler(const v8::FunctionCallbackInfo<v8::Value>& args) {
1860 ApiTestFuzzer::Fuzz();
1861 args.GetReturnValue().Set(v8_num(13.4));
1862}
1863
1864
1865static void GetM(Local<String> name,
1866 const v8::PropertyCallbackInfo<v8::Value>& info) {
1867 ApiTestFuzzer::Fuzz();
1868 info.GetReturnValue().Set(v8_num(876));
1869}
1870
1871
1872THREADED_TEST(GlobalPrototype)static void TestGlobalPrototype(); RegisterThreadedTest register_GlobalPrototype
(TestGlobalPrototype, "GlobalPrototype"); static void TestGlobalPrototype
(); CcTest register_test_GlobalPrototype(TestGlobalPrototype,
"../test/cctest/test-api.cc", "GlobalPrototype", __null, true
, true); static void TestGlobalPrototype()
{
1873 v8::Isolate* isolate = CcTest::isolate();
1874 v8::HandleScope scope(isolate);
1875 v8::Local<v8::FunctionTemplate> func_templ =
1876 v8::FunctionTemplate::New(isolate);
1877 func_templ->PrototypeTemplate()->Set(
1878 isolate, "dummy", v8::FunctionTemplate::New(isolate, DummyCallHandler));
1879 v8::Local<ObjectTemplate> templ = func_templ->InstanceTemplate();
1880 templ->Set(isolate, "x", v8_num(200));
1881 templ->SetAccessor(v8_str("m"), GetM);
1882 LocalContext env(0, templ);
1883 v8::Local<Script> script(v8_compile("dummy()"));
1884 v8::Local<Value> result(script->Run(env.local()).ToLocalChecked());
1885 CHECK_EQ(13.4, result->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13.4),
(result->NumberValue(env.local()).FromJust()), "13.4" " "
"==" " " "result->NumberValue(env.local()).FromJust()")) {
V8_Fatal("../test/cctest/test-api.cc", 1885, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1886 CHECK_EQ(200, v8_run_int32value(v8_compile("x")))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (200), (
v8_run_int32value(v8_compile("x"))), "200" " " "==" " " "v8_run_int32value(v8_compile(\"x\"))"
)) { V8_Fatal("../test/cctest/test-api.cc", 1886, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1887 CHECK_EQ(876, v8_run_int32value(v8_compile("m")))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (876), (
v8_run_int32value(v8_compile("m"))), "876" " " "==" " " "v8_run_int32value(v8_compile(\"m\"))"
)) { V8_Fatal("../test/cctest/test-api.cc", 1887, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1888}
1889
1890
1891THREADED_TEST(ObjectTemplate)static void TestObjectTemplate(); RegisterThreadedTest register_ObjectTemplate
(TestObjectTemplate, "ObjectTemplate"); static void TestObjectTemplate
(); CcTest register_test_ObjectTemplate(TestObjectTemplate, "../test/cctest/test-api.cc"
, "ObjectTemplate", __null, true, true); static void TestObjectTemplate
()
{
1892 LocalContext env;
1893 v8::Isolate* isolate = CcTest::isolate();
1894 v8::HandleScope scope(isolate);
1895 Local<v8::FunctionTemplate> acc =
1896 v8::FunctionTemplate::New(isolate, Returns42);
1897 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("acc"), acc->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1900, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"acc\"), acc->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
1898 ->Set(env.local(), v8_str("acc"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("acc"), acc->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1900, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"acc\"), acc->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
1899 acc->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("acc"), acc->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1900, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"acc\"), acc->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
1900 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("acc"), acc->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1900, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"acc\"), acc->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
1901
1902 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate);
1903 v8::Local<v8::String> class_name = v8_str("the_class_name");
1904 fun->SetClassName(class_name);
1905 Local<ObjectTemplate> templ1 = ObjectTemplate::New(isolate, fun);
1906 templ1->Set(isolate, "x", v8_num(10));
1907 templ1->Set(isolate, "y", v8_num(13));
1908 templ1->Set(v8_str("foo"), acc);
1909 Local<v8::Object> instance1 =
1910 templ1->NewInstance(env.local()).ToLocalChecked();
1911 CHECK(class_name->StrictEquals(instance1->GetConstructorName()))do { if ((__builtin_expect(!!(!(class_name->StrictEquals(instance1
->GetConstructorName()))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1911, "Check failed: %s.", "class_name->StrictEquals(instance1->GetConstructorName())"
); } } while (0)
;
1912 CHECK(env->Global()->Set(env.local(), v8_str("p"), instance1).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("p"), instance1).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1912, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"p\"), instance1).FromJust()"
); } } while (0)
;
1913 CHECK(CompileRun("(p.x == 10)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(p.x == 10)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1913, "Check failed: %s.", "CompileRun(\"(p.x == 10)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1914 CHECK(CompileRun("(p.y == 13)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(p.y == 13)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1914, "Check failed: %s.", "CompileRun(\"(p.y == 13)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1915 CHECK(CompileRun("(p.foo() == 42)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(p.foo() == 42)")
->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 1915, "Check failed: %s.", "CompileRun(\"(p.foo() == 42)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1916 CHECK(CompileRun("(p.foo == acc)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(p.foo == acc)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1916, "Check failed: %s.", "CompileRun(\"(p.foo == acc)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1917 // Ensure that foo become a data field.
1918 CompileRun("p.foo = function() {}");
1919 Local<v8::FunctionTemplate> fun2 = v8::FunctionTemplate::New(isolate);
1920 fun2->PrototypeTemplate()->Set(isolate, "nirk", v8_num(123));
1921 Local<ObjectTemplate> templ2 = fun2->InstanceTemplate();
1922 templ2->Set(isolate, "a", v8_num(12));
1923 templ2->Set(isolate, "b", templ1);
1924 templ2->Set(v8_str("bar"), acc);
1925 templ2->SetAccessorProperty(v8_str("acc"), acc);
1926 Local<v8::Object> instance2 =
1927 templ2->NewInstance(env.local()).ToLocalChecked();
1928 CHECK(env->Global()->Set(env.local(), v8_str("q"), instance2).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("q"), instance2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1928, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"q\"), instance2).FromJust()"
); } } while (0)
;
1929 CHECK(CompileRun("(q.nirk == 123)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.nirk == 123)")
->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 1929, "Check failed: %s.", "CompileRun(\"(q.nirk == 123)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1930 CHECK(CompileRun("(q.a == 12)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.a == 12)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1930, "Check failed: %s.", "CompileRun(\"(q.a == 12)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1931 CHECK(CompileRun("(q.b.x == 10)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.b.x == 10)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1931, "Check failed: %s.", "CompileRun(\"(q.b.x == 10)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1932 CHECK(CompileRun("(q.b.y == 13)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.b.y == 13)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1932, "Check failed: %s.", "CompileRun(\"(q.b.y == 13)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1933 CHECK(CompileRun("(q.b.foo() == 42)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.b.foo() == 42)"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1933, "Check failed: %s.", "CompileRun(\"(q.b.foo() == 42)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1934 CHECK(CompileRun("(q.b.foo === acc)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.b.foo === acc)"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1934, "Check failed: %s.", "CompileRun(\"(q.b.foo === acc)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1935 CHECK(CompileRun("(q.b !== p)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.b !== p)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1935, "Check failed: %s.", "CompileRun(\"(q.b !== p)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1936 CHECK(CompileRun("(q.acc == 42)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.acc == 42)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1936, "Check failed: %s.", "CompileRun(\"(q.acc == 42)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1937 CHECK(CompileRun("(q.bar() == 42)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.bar() == 42)")
->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 1937, "Check failed: %s.", "CompileRun(\"(q.bar() == 42)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1938 CHECK(CompileRun("(q.bar == acc)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.bar == acc)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1938, "Check failed: %s.", "CompileRun(\"(q.bar == acc)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1939
1940 instance2 = templ2->NewInstance(env.local()).ToLocalChecked();
1941 CHECK(env->Global()->Set(env.local(), v8_str("q2"), instance2).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("q2"), instance2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1941, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"q2\"), instance2).FromJust()"
); } } while (0)
;
1942 CHECK(CompileRun("(q2.nirk == 123)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.nirk == 123)"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1942, "Check failed: %s.", "CompileRun(\"(q2.nirk == 123)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1943 CHECK(CompileRun("(q2.a == 12)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.a == 12)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1943, "Check failed: %s.", "CompileRun(\"(q2.a == 12)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1944 CHECK(CompileRun("(q2.b.x == 10)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.b.x == 10)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1944, "Check failed: %s.", "CompileRun(\"(q2.b.x == 10)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1945 CHECK(CompileRun("(q2.b.y == 13)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.b.y == 13)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1945, "Check failed: %s.", "CompileRun(\"(q2.b.y == 13)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1946 CHECK(CompileRun("(q2.b.foo() == 42)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.b.foo() == 42)"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1946, "Check failed: %s.", "CompileRun(\"(q2.b.foo() == 42)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1947 CHECK(CompileRun("(q2.b.foo === acc)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.b.foo === acc)"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1947, "Check failed: %s.", "CompileRun(\"(q2.b.foo === acc)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1948 CHECK(CompileRun("(q2.acc == 42)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.acc == 42)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1948, "Check failed: %s.", "CompileRun(\"(q2.acc == 42)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1949 CHECK(CompileRun("(q2.bar() == 42)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.bar() == 42)"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1949, "Check failed: %s.", "CompileRun(\"(q2.bar() == 42)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1950 CHECK(CompileRun("(q2.bar === acc)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q2.bar === acc)"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1950, "Check failed: %s.", "CompileRun(\"(q2.bar === acc)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1951
1952 CHECK(CompileRun("(q.b !== q2.b)")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("(q.b !== q2.b)")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 1952, "Check failed: %s.", "CompileRun(\"(q.b !== q2.b)\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
1953 CHECK(CompileRun("q.b.x = 17; (q2.b.x == 10)")do { if ((__builtin_expect(!!(!(CompileRun("q.b.x = 17; (q2.b.x == 10)"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1955, "Check failed: %s.", "CompileRun(\"q.b.x = 17; (q2.b.x == 10)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1954 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(CompileRun("q.b.x = 17; (q2.b.x == 10)"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1955, "Check failed: %s.", "CompileRun(\"q.b.x = 17; (q2.b.x == 10)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1955 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("q.b.x = 17; (q2.b.x == 10)"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 1955, "Check failed: %s.", "CompileRun(\"q.b.x = 17; (q2.b.x == 10)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
1956 CHECK(CompileRun("desc1 = Object.getOwnPropertyDescriptor(q, 'acc');"do { if ((__builtin_expect(!!(!(CompileRun("desc1 = Object.getOwnPropertyDescriptor(q, 'acc');"
"(desc1.get === acc)") ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1959, "Check failed: %s."
, "CompileRun(\"desc1 = Object.getOwnPropertyDescriptor(q, 'acc');\" \"(desc1.get === acc)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1957 "(desc1.get === acc)")do { if ((__builtin_expect(!!(!(CompileRun("desc1 = Object.getOwnPropertyDescriptor(q, 'acc');"
"(desc1.get === acc)") ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1959, "Check failed: %s."
, "CompileRun(\"desc1 = Object.getOwnPropertyDescriptor(q, 'acc');\" \"(desc1.get === acc)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1958 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(CompileRun("desc1 = Object.getOwnPropertyDescriptor(q, 'acc');"
"(desc1.get === acc)") ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1959, "Check failed: %s."
, "CompileRun(\"desc1 = Object.getOwnPropertyDescriptor(q, 'acc');\" \"(desc1.get === acc)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1959 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("desc1 = Object.getOwnPropertyDescriptor(q, 'acc');"
"(desc1.get === acc)") ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1959, "Check failed: %s."
, "CompileRun(\"desc1 = Object.getOwnPropertyDescriptor(q, 'acc');\" \"(desc1.get === acc)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
1960 CHECK(CompileRun("desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');"do { if ((__builtin_expect(!!(!(CompileRun("desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');"
"(desc2.get === acc)") ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1963, "Check failed: %s."
, "CompileRun(\"desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');\" \"(desc2.get === acc)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1961 "(desc2.get === acc)")do { if ((__builtin_expect(!!(!(CompileRun("desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');"
"(desc2.get === acc)") ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1963, "Check failed: %s."
, "CompileRun(\"desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');\" \"(desc2.get === acc)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1962 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(CompileRun("desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');"
"(desc2.get === acc)") ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1963, "Check failed: %s."
, "CompileRun(\"desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');\" \"(desc2.get === acc)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
1963 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');"
"(desc2.get === acc)") ->BooleanValue(env.local()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 1963, "Check failed: %s."
, "CompileRun(\"desc2 = Object.getOwnPropertyDescriptor(q2, 'acc');\" \"(desc2.get === acc)\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
1964}
1965
1966THREADED_TEST(IntegerValue)static void TestIntegerValue(); RegisterThreadedTest register_IntegerValue
(TestIntegerValue, "IntegerValue"); static void TestIntegerValue
(); CcTest register_test_IntegerValue(TestIntegerValue, "../test/cctest/test-api.cc"
, "IntegerValue", __null, true, true); static void TestIntegerValue
()
{
1967 LocalContext env;
1968 v8::Isolate* isolate = CcTest::isolate();
1969 v8::HandleScope scope(isolate);
1970
1971 CHECK_EQ(0, CompileRun("undefined")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (CompileRun
("undefined")->IntegerValue(env.local()).FromJust()), "0" " "
"==" " " "CompileRun(\"undefined\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 1971, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
1972}
1973
1974static void GetNirk(Local<String> name,
1975 const v8::PropertyCallbackInfo<v8::Value>& info) {
1976 ApiTestFuzzer::Fuzz();
1977 info.GetReturnValue().Set(v8_num(900));
1978}
1979
1980static void GetRino(Local<String> name,
1981 const v8::PropertyCallbackInfo<v8::Value>& info) {
1982 ApiTestFuzzer::Fuzz();
1983 info.GetReturnValue().Set(v8_num(560));
1984}
1985
1986enum ObjectInstantiationMode {
1987 // Create object using ObjectTemplate::NewInstance.
1988 ObjectTemplate_NewInstance,
1989 // Create object using FunctionTemplate::NewInstance on constructor.
1990 Constructor_GetFunction_NewInstance,
1991 // Create object using new operator on constructor.
1992 Constructor_GetFunction_New
1993};
1994
1995// Test object instance creation using a function template with an instance
1996// template inherited from another function template with accessors and data
1997// properties in prototype template.
1998static void TestObjectTemplateInheritedWithPrototype(
1999 ObjectInstantiationMode mode) {
2000 LocalContext env;
2001 v8::Isolate* isolate = CcTest::isolate();
2002 v8::HandleScope scope(isolate);
2003
2004 Local<v8::FunctionTemplate> fun_A = v8::FunctionTemplate::New(isolate);
2005 fun_A->SetClassName(v8_str("A"));
2006 v8::Local<v8::ObjectTemplate> prototype_templ = fun_A->PrototypeTemplate();
2007 prototype_templ->Set(isolate, "a", v8_num(113));
2008 prototype_templ->SetNativeDataProperty(v8_str("nirk"), GetNirk);
2009 prototype_templ->Set(isolate, "b", v8_num(153));
2010
2011 Local<v8::FunctionTemplate> fun_B = v8::FunctionTemplate::New(isolate);
2012 v8::Local<v8::String> class_name = v8_str("B");
2013 fun_B->SetClassName(class_name);
2014 fun_B->Inherit(fun_A);
2015 prototype_templ = fun_B->PrototypeTemplate();
2016 prototype_templ->Set(isolate, "c", v8_num(713));
2017 prototype_templ->SetNativeDataProperty(v8_str("rino"), GetRino);
2018 prototype_templ->Set(isolate, "d", v8_num(753));
2019
2020 Local<ObjectTemplate> templ = fun_B->InstanceTemplate();
2021 templ->Set(isolate, "x", v8_num(10));
2022 templ->Set(isolate, "y", v8_num(13));
2023
2024 // Perform several iterations to trigger creation from cached boilerplate.
2025 for (int i = 0; i < 3; i++) {
2026 Local<v8::Object> instance;
2027 switch (mode) {
2028 case ObjectTemplate_NewInstance:
2029 instance = templ->NewInstance(env.local()).ToLocalChecked();
2030 break;
2031
2032 case Constructor_GetFunction_NewInstance: {
2033 Local<v8::Function> function_B =
2034 fun_B->GetFunction(env.local()).ToLocalChecked();
2035 instance = function_B->NewInstance(env.local()).ToLocalChecked();
2036 break;
2037 }
2038 case Constructor_GetFunction_New: {
2039 Local<v8::Function> function_B =
2040 fun_B->GetFunction(env.local()).ToLocalChecked();
2041 if (i == 0) {
2042 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), class_name, function_B) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2044, "Check failed: %s.", "env->Global() ->Set(env.local(), class_name, function_B) .FromJust()"
); } } while (0)
2043 ->Set(env.local(), class_name, function_B)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), class_name, function_B) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2044, "Check failed: %s.", "env->Global() ->Set(env.local(), class_name, function_B) .FromJust()"
); } } while (0)
2044 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), class_name, function_B) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2044, "Check failed: %s.", "env->Global() ->Set(env.local(), class_name, function_B) .FromJust()"
); } } while (0)
;
2045 }
2046 instance =
2047 CompileRun("new B()")->ToObject(env.local()).ToLocalChecked();
2048 break;
2049 }
2050 default:
2051 UNREACHABLE()V8_Fatal("../test/cctest/test-api.cc", 2051, "unreachable code"
)
;
2052 }
2053
2054 CHECK(class_name->StrictEquals(instance->GetConstructorName()))do { if ((__builtin_expect(!!(!(class_name->StrictEquals(instance
->GetConstructorName()))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2054, "Check failed: %s.", "class_name->StrictEquals(instance->GetConstructorName())"
); } } while (0)
;
2055 CHECK(env->Global()->Set(env.local(), v8_str("o"), instance).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("o"), instance).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2055, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"o\"), instance).FromJust()"
); } } while (0)
;
2056
2057 CHECK_EQ(10, CompileRun("o.x")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10), (
CompileRun("o.x")->IntegerValue(env.local()).FromJust()), "10"
" " "==" " " "CompileRun(\"o.x\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2057, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2058 CHECK_EQ(13, CompileRun("o.y")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
CompileRun("o.y")->IntegerValue(env.local()).FromJust()), "13"
" " "==" " " "CompileRun(\"o.y\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2059
2060 CHECK_EQ(113, CompileRun("o.a")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (113), (
CompileRun("o.a")->IntegerValue(env.local()).FromJust()), "113"
" " "==" " " "CompileRun(\"o.a\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2060, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2061 CHECK_EQ(900, CompileRun("o.nirk")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (900), (
CompileRun("o.nirk")->IntegerValue(env.local()).FromJust()
), "900" " " "==" " " "CompileRun(\"o.nirk\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2061, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2062 CHECK_EQ(153, CompileRun("o.b")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (153), (
CompileRun("o.b")->IntegerValue(env.local()).FromJust()), "153"
" " "==" " " "CompileRun(\"o.b\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2063 CHECK_EQ(713, CompileRun("o.c")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (713), (
CompileRun("o.c")->IntegerValue(env.local()).FromJust()), "713"
" " "==" " " "CompileRun(\"o.c\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2063, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2064 CHECK_EQ(560, CompileRun("o.rino")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (560), (
CompileRun("o.rino")->IntegerValue(env.local()).FromJust()
), "560" " " "==" " " "CompileRun(\"o.rino\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2064, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2065 CHECK_EQ(753, CompileRun("o.d")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (753), (
CompileRun("o.d")->IntegerValue(env.local()).FromJust()), "753"
" " "==" " " "CompileRun(\"o.d\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2065, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2066 }
2067}
2068
2069THREADED_TEST(TestObjectTemplateInheritedWithAccessorsInPrototype1)static void TestTestObjectTemplateInheritedWithAccessorsInPrototype1
(); RegisterThreadedTest register_TestObjectTemplateInheritedWithAccessorsInPrototype1
(TestTestObjectTemplateInheritedWithAccessorsInPrototype1, "TestObjectTemplateInheritedWithAccessorsInPrototype1"
); static void TestTestObjectTemplateInheritedWithAccessorsInPrototype1
(); CcTest register_test_TestObjectTemplateInheritedWithAccessorsInPrototype1
(TestTestObjectTemplateInheritedWithAccessorsInPrototype1, "../test/cctest/test-api.cc"
, "TestObjectTemplateInheritedWithAccessorsInPrototype1", __null
, true, true); static void TestTestObjectTemplateInheritedWithAccessorsInPrototype1
()
{
2070 TestObjectTemplateInheritedWithPrototype(ObjectTemplate_NewInstance);
2071}
2072
2073THREADED_TEST(TestObjectTemplateInheritedWithAccessorsInPrototype2)static void TestTestObjectTemplateInheritedWithAccessorsInPrototype2
(); RegisterThreadedTest register_TestObjectTemplateInheritedWithAccessorsInPrototype2
(TestTestObjectTemplateInheritedWithAccessorsInPrototype2, "TestObjectTemplateInheritedWithAccessorsInPrototype2"
); static void TestTestObjectTemplateInheritedWithAccessorsInPrototype2
(); CcTest register_test_TestObjectTemplateInheritedWithAccessorsInPrototype2
(TestTestObjectTemplateInheritedWithAccessorsInPrototype2, "../test/cctest/test-api.cc"
, "TestObjectTemplateInheritedWithAccessorsInPrototype2", __null
, true, true); static void TestTestObjectTemplateInheritedWithAccessorsInPrototype2
()
{
2074 TestObjectTemplateInheritedWithPrototype(Constructor_GetFunction_NewInstance);
2075}
2076
2077THREADED_TEST(TestObjectTemplateInheritedWithAccessorsInPrototype3)static void TestTestObjectTemplateInheritedWithAccessorsInPrototype3
(); RegisterThreadedTest register_TestObjectTemplateInheritedWithAccessorsInPrototype3
(TestTestObjectTemplateInheritedWithAccessorsInPrototype3, "TestObjectTemplateInheritedWithAccessorsInPrototype3"
); static void TestTestObjectTemplateInheritedWithAccessorsInPrototype3
(); CcTest register_test_TestObjectTemplateInheritedWithAccessorsInPrototype3
(TestTestObjectTemplateInheritedWithAccessorsInPrototype3, "../test/cctest/test-api.cc"
, "TestObjectTemplateInheritedWithAccessorsInPrototype3", __null
, true, true); static void TestTestObjectTemplateInheritedWithAccessorsInPrototype3
()
{
2078 TestObjectTemplateInheritedWithPrototype(Constructor_GetFunction_New);
2079}
2080
2081// Test object instance creation using a function template without an instance
2082// template inherited from another function template.
2083static void TestObjectTemplateInheritedWithoutInstanceTemplate(
2084 ObjectInstantiationMode mode) {
2085 LocalContext env;
2086 v8::Isolate* isolate = CcTest::isolate();
2087 v8::HandleScope scope(isolate);
2088
2089 Local<v8::FunctionTemplate> fun_A = v8::FunctionTemplate::New(isolate);
2090 fun_A->SetClassName(v8_str("A"));
2091
2092 Local<ObjectTemplate> templ_A = fun_A->InstanceTemplate();
2093 templ_A->SetNativeDataProperty(v8_str("nirk"), GetNirk);
2094 templ_A->SetNativeDataProperty(v8_str("rino"), GetRino);
2095
2096 Local<v8::FunctionTemplate> fun_B = v8::FunctionTemplate::New(isolate);
2097 v8::Local<v8::String> class_name = v8_str("B");
2098 fun_B->SetClassName(class_name);
2099 fun_B->Inherit(fun_A);
2100
2101 // Perform several iterations to trigger creation from cached boilerplate.
2102 for (int i = 0; i < 3; i++) {
2103 Local<v8::Object> instance;
2104 switch (mode) {
2105 case Constructor_GetFunction_NewInstance: {
2106 Local<v8::Function> function_B =
2107 fun_B->GetFunction(env.local()).ToLocalChecked();
2108 instance = function_B->NewInstance(env.local()).ToLocalChecked();
2109 break;
2110 }
2111 case Constructor_GetFunction_New: {
2112 Local<v8::Function> function_B =
2113 fun_B->GetFunction(env.local()).ToLocalChecked();
2114 if (i == 0) {
2115 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), class_name, function_B) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2117, "Check failed: %s.", "env->Global() ->Set(env.local(), class_name, function_B) .FromJust()"
); } } while (0)
2116 ->Set(env.local(), class_name, function_B)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), class_name, function_B) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2117, "Check failed: %s.", "env->Global() ->Set(env.local(), class_name, function_B) .FromJust()"
); } } while (0)
2117 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), class_name, function_B) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2117, "Check failed: %s.", "env->Global() ->Set(env.local(), class_name, function_B) .FromJust()"
); } } while (0)
;
2118 }
2119 instance =
2120 CompileRun("new B()")->ToObject(env.local()).ToLocalChecked();
2121 break;
2122 }
2123 default:
2124 UNREACHABLE()V8_Fatal("../test/cctest/test-api.cc", 2124, "unreachable code"
)
;
2125 }
2126
2127 CHECK(class_name->StrictEquals(instance->GetConstructorName()))do { if ((__builtin_expect(!!(!(class_name->StrictEquals(instance
->GetConstructorName()))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2127, "Check failed: %s.", "class_name->StrictEquals(instance->GetConstructorName())"
); } } while (0)
;
2128 CHECK(env->Global()->Set(env.local(), v8_str("o"), instance).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("o"), instance).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2128, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"o\"), instance).FromJust()"
); } } while (0)
;
2129
2130 CHECK_EQ(900, CompileRun("o.nirk")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (900), (
CompileRun("o.nirk")->IntegerValue(env.local()).FromJust()
), "900" " " "==" " " "CompileRun(\"o.nirk\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2130, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2131 CHECK_EQ(560, CompileRun("o.rino")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (560), (
CompileRun("o.rino")->IntegerValue(env.local()).FromJust()
), "560" " " "==" " " "CompileRun(\"o.rino\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2131, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2132 }
2133}
2134
2135THREADED_TEST(TestObjectTemplateInheritedWithPrototype1)static void TestTestObjectTemplateInheritedWithPrototype1(); RegisterThreadedTest
register_TestObjectTemplateInheritedWithPrototype1(TestTestObjectTemplateInheritedWithPrototype1
, "TestObjectTemplateInheritedWithPrototype1"); static void TestTestObjectTemplateInheritedWithPrototype1
(); CcTest register_test_TestObjectTemplateInheritedWithPrototype1
(TestTestObjectTemplateInheritedWithPrototype1, "../test/cctest/test-api.cc"
, "TestObjectTemplateInheritedWithPrototype1", __null, true, true
); static void TestTestObjectTemplateInheritedWithPrototype1(
)
{
2136 TestObjectTemplateInheritedWithoutInstanceTemplate(
2137 Constructor_GetFunction_NewInstance);
2138}
2139
2140THREADED_TEST(TestObjectTemplateInheritedWithPrototype2)static void TestTestObjectTemplateInheritedWithPrototype2(); RegisterThreadedTest
register_TestObjectTemplateInheritedWithPrototype2(TestTestObjectTemplateInheritedWithPrototype2
, "TestObjectTemplateInheritedWithPrototype2"); static void TestTestObjectTemplateInheritedWithPrototype2
(); CcTest register_test_TestObjectTemplateInheritedWithPrototype2
(TestTestObjectTemplateInheritedWithPrototype2, "../test/cctest/test-api.cc"
, "TestObjectTemplateInheritedWithPrototype2", __null, true, true
); static void TestTestObjectTemplateInheritedWithPrototype2(
)
{
2141 TestObjectTemplateInheritedWithoutInstanceTemplate(
2142 Constructor_GetFunction_New);
2143}
2144
2145static void GetFlabby(const v8::FunctionCallbackInfo<v8::Value>& args) {
2146 ApiTestFuzzer::Fuzz();
2147 args.GetReturnValue().Set(v8_num(17.2));
2148}
2149
2150
2151static void GetKnurd(Local<String> property,
2152 const v8::PropertyCallbackInfo<v8::Value>& info) {
2153 ApiTestFuzzer::Fuzz();
2154 info.GetReturnValue().Set(v8_num(15.2));
2155}
2156
2157
2158THREADED_TEST(DescriptorInheritance)static void TestDescriptorInheritance(); RegisterThreadedTest
register_DescriptorInheritance(TestDescriptorInheritance, "DescriptorInheritance"
); static void TestDescriptorInheritance(); CcTest register_test_DescriptorInheritance
(TestDescriptorInheritance, "../test/cctest/test-api.cc", "DescriptorInheritance"
, __null, true, true); static void TestDescriptorInheritance(
)
{
2159 v8::Isolate* isolate = CcTest::isolate();
2160 v8::HandleScope scope(isolate);
2161 v8::Local<v8::FunctionTemplate> super = v8::FunctionTemplate::New(isolate);
2162 super->PrototypeTemplate()->Set(isolate, "flabby",
2163 v8::FunctionTemplate::New(isolate,
2164 GetFlabby));
2165 super->PrototypeTemplate()->Set(isolate, "PI", v8_num(3.14));
2166
2167 super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd);
2168
2169 v8::Local<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(isolate);
2170 base1->Inherit(super);
2171 base1->PrototypeTemplate()->Set(isolate, "v1", v8_num(20.1));
2172
2173 v8::Local<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New(isolate);
2174 base2->Inherit(super);
2175 base2->PrototypeTemplate()->Set(isolate, "v2", v8_num(10.1));
2176
2177 LocalContext env;
2178
2179 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("s"), super->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2182, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"s\"), super->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2180 ->Set(env.local(), v8_str("s"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("s"), super->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2182, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"s\"), super->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2181 super->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("s"), super->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2182, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"s\"), super->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2182 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("s"), super->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2182, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"s\"), super->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
2183 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("base1"), base1->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2186, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"base1\"), base1->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2184 ->Set(env.local(), v8_str("base1"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("base1"), base1->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2186, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"base1\"), base1->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2185 base1->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("base1"), base1->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2186, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"base1\"), base1->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2186 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("base1"), base1->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2186, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"base1\"), base1->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
2187 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("base2"), base2->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2190, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"base2\"), base2->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2188 ->Set(env.local(), v8_str("base2"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("base2"), base2->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2190, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"base2\"), base2->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2189 base2->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("base2"), base2->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2190, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"base2\"), base2->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2190 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("base2"), base2->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2190, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"base2\"), base2->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
2191
2192 // Checks right __proto__ chain.
2193 CHECK(CompileRun("base1.prototype.__proto__ == s.prototype")do { if ((__builtin_expect(!!(!(CompileRun("base1.prototype.__proto__ == s.prototype"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2195, "Check failed: %s.", "CompileRun(\"base1.prototype.__proto__ == s.prototype\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2194 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(CompileRun("base1.prototype.__proto__ == s.prototype"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2195, "Check failed: %s.", "CompileRun(\"base1.prototype.__proto__ == s.prototype\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2195 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("base1.prototype.__proto__ == s.prototype"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2195, "Check failed: %s.", "CompileRun(\"base1.prototype.__proto__ == s.prototype\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
2196 CHECK(CompileRun("base2.prototype.__proto__ == s.prototype")do { if ((__builtin_expect(!!(!(CompileRun("base2.prototype.__proto__ == s.prototype"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2198, "Check failed: %s.", "CompileRun(\"base2.prototype.__proto__ == s.prototype\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2197 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(CompileRun("base2.prototype.__proto__ == s.prototype"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2198, "Check failed: %s.", "CompileRun(\"base2.prototype.__proto__ == s.prototype\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2198 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("base2.prototype.__proto__ == s.prototype"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2198, "Check failed: %s.", "CompileRun(\"base2.prototype.__proto__ == s.prototype\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
2199
2200 CHECK(v8_compile("s.prototype.PI == 3.14")do { if ((__builtin_expect(!!(!(v8_compile("s.prototype.PI == 3.14"
) ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env
.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2204, "Check failed: %s.", "v8_compile(\"s.prototype.PI == 3.14\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2201 ->Run(env.local())do { if ((__builtin_expect(!!(!(v8_compile("s.prototype.PI == 3.14"
) ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env
.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2204, "Check failed: %s.", "v8_compile(\"s.prototype.PI == 3.14\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2202 .ToLocalChecked()do { if ((__builtin_expect(!!(!(v8_compile("s.prototype.PI == 3.14"
) ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env
.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2204, "Check failed: %s.", "v8_compile(\"s.prototype.PI == 3.14\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2203 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(v8_compile("s.prototype.PI == 3.14"
) ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env
.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2204, "Check failed: %s.", "v8_compile(\"s.prototype.PI == 3.14\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2204 .FromJust())do { if ((__builtin_expect(!!(!(v8_compile("s.prototype.PI == 3.14"
) ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env
.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2204, "Check failed: %s.", "v8_compile(\"s.prototype.PI == 3.14\") ->Run(env.local()) .ToLocalChecked() ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
2205
2206 // Instance accessor should not be visible on function object or its prototype
2207 CHECK(do { if ((__builtin_expect(!!(!(CompileRun("s.knurd == undefined"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2208, "Check failed: %s.", "CompileRun(\"s.knurd == undefined\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
2208 CompileRun("s.knurd == undefined")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("s.knurd == undefined"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2208, "Check failed: %s.", "CompileRun(\"s.knurd == undefined\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
2209 CHECK(CompileRun("s.prototype.knurd == undefined")do { if ((__builtin_expect(!!(!(CompileRun("s.prototype.knurd == undefined"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2211, "Check failed: %s.", "CompileRun(\"s.prototype.knurd == undefined\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2210 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(CompileRun("s.prototype.knurd == undefined"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2211, "Check failed: %s.", "CompileRun(\"s.prototype.knurd == undefined\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2211 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("s.prototype.knurd == undefined"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2211, "Check failed: %s.", "CompileRun(\"s.prototype.knurd == undefined\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
2212 CHECK(CompileRun("base1.prototype.knurd == undefined")do { if ((__builtin_expect(!!(!(CompileRun("base1.prototype.knurd == undefined"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2214, "Check failed: %s.", "CompileRun(\"base1.prototype.knurd == undefined\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2213 ->BooleanValue(env.local())do { if ((__builtin_expect(!!(!(CompileRun("base1.prototype.knurd == undefined"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2214, "Check failed: %s.", "CompileRun(\"base1.prototype.knurd == undefined\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
2214 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("base1.prototype.knurd == undefined"
) ->BooleanValue(env.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2214, "Check failed: %s.", "CompileRun(\"base1.prototype.knurd == undefined\") ->BooleanValue(env.local()) .FromJust()"
); } } while (0)
;
2215
2216 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), base1->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2221, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), base1->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2217 ->Set(env.local(), v8_str("obj"), base1->GetFunction(env.local())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), base1->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2221, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), base1->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2218 .ToLocalChecked()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), base1->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2221, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), base1->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2219 ->NewInstance(env.local())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), base1->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2221, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), base1->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2220 .ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), base1->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2221, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), base1->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2221 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), base1->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2221, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), base1->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
2222 CHECK_EQ(17.2,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17.2),
(CompileRun("obj.flabby()")->NumberValue(env.local()).FromJust
()), "17.2" " " "==" " " "CompileRun(\"obj.flabby()\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2223, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2223 CompileRun("obj.flabby()")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17.2),
(CompileRun("obj.flabby()")->NumberValue(env.local()).FromJust
()), "17.2" " " "==" " " "CompileRun(\"obj.flabby()\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2223, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2224 CHECK(CompileRun("'flabby' in obj")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("'flabby' in obj")
->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 2224, "Check failed: %s.", "CompileRun(\"'flabby' in obj\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
2225 CHECK_EQ(15.2, CompileRun("obj.knurd")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15.2),
(CompileRun("obj.knurd")->NumberValue(env.local()).FromJust
()), "15.2" " " "==" " " "CompileRun(\"obj.knurd\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2225, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2226 CHECK(CompileRun("'knurd' in obj")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("'knurd' in obj")->
BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2226, "Check failed: %s.", "CompileRun(\"'knurd' in obj\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
2227 CHECK_EQ(20.1, CompileRun("obj.v1")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (20.1),
(CompileRun("obj.v1")->NumberValue(env.local()).FromJust(
)), "20.1" " " "==" " " "CompileRun(\"obj.v1\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2227, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2228
2229 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj2"), base2->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2234, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj2\"), base2->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2230 ->Set(env.local(), v8_str("obj2"), base2->GetFunction(env.local())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj2"), base2->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2234, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj2\"), base2->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2231 .ToLocalChecked()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj2"), base2->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2234, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj2\"), base2->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2232 ->NewInstance(env.local())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj2"), base2->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2234, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj2\"), base2->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2233 .ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj2"), base2->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2234, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj2\"), base2->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
2234 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj2"), base2->GetFunction(env.local()) .
ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2234, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj2\"), base2->GetFunction(env.local()) .ToLocalChecked() ->NewInstance(env.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
2235 CHECK_EQ(17.2,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17.2),
(CompileRun("obj2.flabby()")->NumberValue(env.local()).FromJust
()), "17.2" " " "==" " " "CompileRun(\"obj2.flabby()\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2236, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2236 CompileRun("obj2.flabby()")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17.2),
(CompileRun("obj2.flabby()")->NumberValue(env.local()).FromJust
()), "17.2" " " "==" " " "CompileRun(\"obj2.flabby()\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2236, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2237 CHECK(CompileRun("'flabby' in obj2")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("'flabby' in obj2"
)->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2237, "Check failed: %s.", "CompileRun(\"'flabby' in obj2\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
2238 CHECK_EQ(15.2, CompileRun("obj2.knurd")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15.2),
(CompileRun("obj2.knurd")->NumberValue(env.local()).FromJust
()), "15.2" " " "==" " " "CompileRun(\"obj2.knurd\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2238, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2239 CHECK(CompileRun("'knurd' in obj2")->BooleanValue(env.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("'knurd' in obj2")
->BooleanValue(env.local()).FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 2239, "Check failed: %s.", "CompileRun(\"'knurd' in obj2\")->BooleanValue(env.local()).FromJust()"
); } } while (0)
;
2240 CHECK_EQ(10.1, CompileRun("obj2.v2")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.1),
(CompileRun("obj2.v2")->NumberValue(env.local()).FromJust
()), "10.1" " " "==" " " "CompileRun(\"obj2.v2\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2240, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2241
2242 // base1 and base2 cannot cross reference to each's prototype
2243 CHECK(CompileRun("obj.v2")->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRun("obj.v2")->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2243, "Check failed: %s."
, "CompileRun(\"obj.v2\")->IsUndefined()"); } } while (0)
;
2244 CHECK(CompileRun("obj2.v1")->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRun("obj2.v1")->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2244, "Check failed: %s."
, "CompileRun(\"obj2.v1\")->IsUndefined()"); } } while (0)
;
2245}
2246
2247THREADED_TEST(DescriptorInheritance2)static void TestDescriptorInheritance2(); RegisterThreadedTest
register_DescriptorInheritance2(TestDescriptorInheritance2, "DescriptorInheritance2"
); static void TestDescriptorInheritance2(); CcTest register_test_DescriptorInheritance2
(TestDescriptorInheritance2, "../test/cctest/test-api.cc", "DescriptorInheritance2"
, __null, true, true); static void TestDescriptorInheritance2
()
{
2248 LocalContext env;
2249 v8::Isolate* isolate = CcTest::isolate();
2250 v8::HandleScope scope(isolate);
2251 v8::Local<v8::FunctionTemplate> fun_A = v8::FunctionTemplate::New(isolate);
2252 fun_A->SetClassName(v8_str("A"));
2253 fun_A->InstanceTemplate()->SetNativeDataProperty(v8_str("knurd1"), GetKnurd);
2254 fun_A->InstanceTemplate()->SetNativeDataProperty(v8_str("nirk1"), GetNirk);
2255 fun_A->InstanceTemplate()->SetNativeDataProperty(v8_str("rino1"), GetRino);
2256
2257 v8::Local<v8::FunctionTemplate> fun_B = v8::FunctionTemplate::New(isolate);
2258 fun_B->SetClassName(v8_str("B"));
2259 fun_B->Inherit(fun_A);
2260
2261 v8::Local<v8::FunctionTemplate> fun_C = v8::FunctionTemplate::New(isolate);
2262 fun_C->SetClassName(v8_str("C"));
2263 fun_C->Inherit(fun_B);
2264 fun_C->InstanceTemplate()->SetNativeDataProperty(v8_str("knurd2"), GetKnurd);
2265 fun_C->InstanceTemplate()->SetNativeDataProperty(v8_str("nirk2"), GetNirk);
2266 fun_C->InstanceTemplate()->SetNativeDataProperty(v8_str("rino2"), GetRino);
2267
2268 v8::Local<v8::FunctionTemplate> fun_D = v8::FunctionTemplate::New(isolate);
2269 fun_D->SetClassName(v8_str("D"));
2270 fun_D->Inherit(fun_C);
2271
2272 v8::Local<v8::FunctionTemplate> fun_E = v8::FunctionTemplate::New(isolate);
2273 fun_E->SetClassName(v8_str("E"));
2274 fun_E->Inherit(fun_D);
2275 fun_E->InstanceTemplate()->SetNativeDataProperty(v8_str("knurd3"), GetKnurd);
2276 fun_E->InstanceTemplate()->SetNativeDataProperty(v8_str("nirk3"), GetNirk);
2277 fun_E->InstanceTemplate()->SetNativeDataProperty(v8_str("rino3"), GetRino);
2278
2279 v8::Local<v8::FunctionTemplate> fun_F = v8::FunctionTemplate::New(isolate);
2280 fun_F->SetClassName(v8_str("F"));
2281 fun_F->Inherit(fun_E);
2282 v8::Local<v8::ObjectTemplate> templ = fun_F->InstanceTemplate();
2283 const int kDataPropertiesNumber = 100;
2284 for (int i = 0; i < kDataPropertiesNumber; i++) {
2285 v8::Local<v8::Value> val = v8_num(i);
2286 v8::Local<v8::String> val_str = val->ToString(env.local()).ToLocalChecked();
2287 v8::Local<v8::String> name = String::Concat(v8_str("p"), val_str);
2288
2289 templ->Set(name, val);
2290 templ->Set(val_str, val);
2291 }
2292
2293 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("F"), fun_F->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2296, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"F\"), fun_F->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2294 ->Set(env.local(), v8_str("F"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("F"), fun_F->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2296, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"F\"), fun_F->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2295 fun_F->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("F"), fun_F->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2296, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"F\"), fun_F->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2296 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("F"), fun_F->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2296, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"F\"), fun_F->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
2297
2298 v8::Local<v8::Script> script = v8_compile("o = new F()");
2299
2300 for (int i = 0; i < 100; i++) {
2301 v8::HandleScope scope(isolate);
2302 script->Run(env.local()).ToLocalChecked();
2303 }
2304 v8::Local<v8::Object> object = script->Run(env.local())
2305 .ToLocalChecked()
2306 ->ToObject(env.local())
2307 .ToLocalChecked();
2308
2309 CHECK_EQ(15.2, CompileRun("o.knurd1")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15.2),
(CompileRun("o.knurd1")->NumberValue(env.local()).FromJust
()), "15.2" " " "==" " " "CompileRun(\"o.knurd1\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2309, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2310 CHECK_EQ(15.2, CompileRun("o.knurd2")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15.2),
(CompileRun("o.knurd2")->NumberValue(env.local()).FromJust
()), "15.2" " " "==" " " "CompileRun(\"o.knurd2\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2310, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2311 CHECK_EQ(15.2, CompileRun("o.knurd3")->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15.2),
(CompileRun("o.knurd3")->NumberValue(env.local()).FromJust
()), "15.2" " " "==" " " "CompileRun(\"o.knurd3\")->NumberValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2311, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2312
2313 CHECK_EQ(900, CompileRun("o.nirk1")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (900), (
CompileRun("o.nirk1")->IntegerValue(env.local()).FromJust(
)), "900" " " "==" " " "CompileRun(\"o.nirk1\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2313, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2314 CHECK_EQ(900, CompileRun("o.nirk2")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (900), (
CompileRun("o.nirk2")->IntegerValue(env.local()).FromJust(
)), "900" " " "==" " " "CompileRun(\"o.nirk2\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2314, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2315 CHECK_EQ(900, CompileRun("o.nirk3")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (900), (
CompileRun("o.nirk3")->IntegerValue(env.local()).FromJust(
)), "900" " " "==" " " "CompileRun(\"o.nirk3\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2315, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2316
2317 CHECK_EQ(560, CompileRun("o.rino1")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (560), (
CompileRun("o.rino1")->IntegerValue(env.local()).FromJust(
)), "560" " " "==" " " "CompileRun(\"o.rino1\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2317, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2318 CHECK_EQ(560, CompileRun("o.rino2")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (560), (
CompileRun("o.rino2")->IntegerValue(env.local()).FromJust(
)), "560" " " "==" " " "CompileRun(\"o.rino2\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2318, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2319 CHECK_EQ(560, CompileRun("o.rino3")->IntegerValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (560), (
CompileRun("o.rino3")->IntegerValue(env.local()).FromJust(
)), "560" " " "==" " " "CompileRun(\"o.rino3\")->IntegerValue(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2319, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2320
2321 for (int i = 0; i < kDataPropertiesNumber; i++) {
2322 v8::Local<v8::Value> val = v8_num(i);
2323 v8::Local<v8::String> val_str = val->ToString(env.local()).ToLocalChecked();
2324 v8::Local<v8::String> name = String::Concat(v8_str("p"), val_str);
2325
2326 CHECK_EQ(i, object->Get(env.local(), name)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i), (object
->Get(env.local(), name) .ToLocalChecked() ->IntegerValue
(env.local()) .FromJust()), "i" " " "==" " " "object->Get(env.local(), name) .ToLocalChecked() ->IntegerValue(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2329, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2327 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i), (object
->Get(env.local(), name) .ToLocalChecked() ->IntegerValue
(env.local()) .FromJust()), "i" " " "==" " " "object->Get(env.local(), name) .ToLocalChecked() ->IntegerValue(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2329, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2328 ->IntegerValue(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i), (object
->Get(env.local(), name) .ToLocalChecked() ->IntegerValue
(env.local()) .FromJust()), "i" " " "==" " " "object->Get(env.local(), name) .ToLocalChecked() ->IntegerValue(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2329, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2329 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i), (object
->Get(env.local(), name) .ToLocalChecked() ->IntegerValue
(env.local()) .FromJust()), "i" " " "==" " " "object->Get(env.local(), name) .ToLocalChecked() ->IntegerValue(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2329, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2330 CHECK_EQ(i, object->Get(env.local(), val)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i), (object
->Get(env.local(), val) .ToLocalChecked() ->IntegerValue
(env.local()) .FromJust()), "i" " " "==" " " "object->Get(env.local(), val) .ToLocalChecked() ->IntegerValue(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2333, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2331 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i), (object
->Get(env.local(), val) .ToLocalChecked() ->IntegerValue
(env.local()) .FromJust()), "i" " " "==" " " "object->Get(env.local(), val) .ToLocalChecked() ->IntegerValue(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2333, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2332 ->IntegerValue(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i), (object
->Get(env.local(), val) .ToLocalChecked() ->IntegerValue
(env.local()) .FromJust()), "i" " " "==" " " "object->Get(env.local(), val) .ToLocalChecked() ->IntegerValue(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2333, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2333 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i), (object
->Get(env.local(), val) .ToLocalChecked() ->IntegerValue
(env.local()) .FromJust()), "i" " " "==" " " "object->Get(env.local(), val) .ToLocalChecked() ->IntegerValue(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2333, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2334 }
2335}
2336
2337
2338// Helper functions for Interceptor/Accessor interaction tests
2339
2340void SimpleAccessorGetter(Local<String> name,
2341 const v8::PropertyCallbackInfo<v8::Value>& info) {
2342 Local<Object> self = Local<Object>::Cast(info.This());
2343 info.GetReturnValue().Set(self->Get(info.GetIsolate()->GetCurrentContext(),
2344 String::Concat(v8_str("accessor_"), name))
2345 .ToLocalChecked());
2346}
2347
2348void SimpleAccessorSetter(Local<String> name, Local<Value> value,
2349 const v8::PropertyCallbackInfo<void>& info) {
2350 Local<Object> self = Local<Object>::Cast(info.This());
2351 CHECK(self->Set(info.GetIsolate()->GetCurrentContext(),do { if ((__builtin_expect(!!(!(self->Set(info.GetIsolate(
)->GetCurrentContext(), String::Concat(v8_str("accessor_")
, name), value) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2353, "Check failed: %s.", "self->Set(info.GetIsolate()->GetCurrentContext(), String::Concat(v8_str(\"accessor_\"), name), value) .FromJust()"
); } } while (0)
2352 String::Concat(v8_str("accessor_"), name), value)do { if ((__builtin_expect(!!(!(self->Set(info.GetIsolate(
)->GetCurrentContext(), String::Concat(v8_str("accessor_")
, name), value) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2353, "Check failed: %s.", "self->Set(info.GetIsolate()->GetCurrentContext(), String::Concat(v8_str(\"accessor_\"), name), value) .FromJust()"
); } } while (0)
2353 .FromJust())do { if ((__builtin_expect(!!(!(self->Set(info.GetIsolate(
)->GetCurrentContext(), String::Concat(v8_str("accessor_")
, name), value) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2353, "Check failed: %s.", "self->Set(info.GetIsolate()->GetCurrentContext(), String::Concat(v8_str(\"accessor_\"), name), value) .FromJust()"
); } } while (0)
;
2354}
2355
2356void SymbolAccessorGetter(Local<Name> name,
2357 const v8::PropertyCallbackInfo<v8::Value>& info) {
2358 CHECK(name->IsSymbol())do { if ((__builtin_expect(!!(!(name->IsSymbol())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2358, "Check failed: %s."
, "name->IsSymbol()"); } } while (0)
;
2359 Local<Symbol> sym = Local<Symbol>::Cast(name);
2360 if (sym->Name()->IsUndefined())
2361 return;
2362 SimpleAccessorGetter(Local<String>::Cast(sym->Name()), info);
2363}
2364
2365void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
2366 const v8::PropertyCallbackInfo<void>& info) {
2367 CHECK(name->IsSymbol())do { if ((__builtin_expect(!!(!(name->IsSymbol())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2367, "Check failed: %s."
, "name->IsSymbol()"); } } while (0)
;
2368 Local<Symbol> sym = Local<Symbol>::Cast(name);
2369 if (sym->Name()->IsUndefined())
2370 return;
2371 SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info);
2372}
2373
2374void SymbolAccessorGetterReturnsDefault(
2375 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
2376 CHECK(name->IsSymbol())do { if ((__builtin_expect(!!(!(name->IsSymbol())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2376, "Check failed: %s."
, "name->IsSymbol()"); } } while (0)
;
2377 Local<Symbol> sym = Local<Symbol>::Cast(name);
2378 if (sym->Name()->IsUndefined()) return;
2379 info.GetReturnValue().Set(info.Data());
2380}
2381
2382static void ThrowingSymbolAccessorGetter(
2383 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
2384 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(name));
2385}
2386
2387
2388THREADED_TEST(AccessorIsPreservedOnAttributeChange)static void TestAccessorIsPreservedOnAttributeChange(); RegisterThreadedTest
register_AccessorIsPreservedOnAttributeChange(TestAccessorIsPreservedOnAttributeChange
, "AccessorIsPreservedOnAttributeChange"); static void TestAccessorIsPreservedOnAttributeChange
(); CcTest register_test_AccessorIsPreservedOnAttributeChange
(TestAccessorIsPreservedOnAttributeChange, "../test/cctest/test-api.cc"
, "AccessorIsPreservedOnAttributeChange", __null, true, true)
; static void TestAccessorIsPreservedOnAttributeChange()
{
2389 v8::Isolate* isolate = CcTest::isolate();
2390 v8::HandleScope scope(isolate);
2391 LocalContext env;
2392 v8::Local<v8::Value> res = CompileRun("var a = []; a;");
2393 i::Handle<i::JSReceiver> a(v8::Utils::OpenHandle(v8::Object::Cast(*res)));
2394 CHECK(a->map()->instance_descriptors()->IsFixedArray())do { if ((__builtin_expect(!!(!(a->map()->instance_descriptors
()->IsFixedArray())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2394, "Check failed: %s.", "a->map()->instance_descriptors()->IsFixedArray()"
); } } while (0)
;
2395 CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0)do { if (std::string* _msg = ::v8::base::CheckGTImpl( (i::FixedArray
::cast(a->map()->instance_descriptors())->length()),
(0), "i::FixedArray::cast(a->map()->instance_descriptors())->length()"
" " ">" " " "0")) { V8_Fatal("../test/cctest/test-api.cc"
, 2395, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2396 CompileRun("Object.defineProperty(a, 'length', { writable: false });");
2397 CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i::FixedArray
::cast(a->map()->instance_descriptors())->length()),
(0), "i::FixedArray::cast(a->map()->instance_descriptors())->length()"
" " "==" " " "0")) { V8_Fatal("../test/cctest/test-api.cc", 2397
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
2398 // But we should still have an AccessorInfo.
2399 i::Handle<i::String> name(v8::Utils::OpenHandle(*v8_str("length")));
2400 i::LookupIterator it(a, name, i::LookupIterator::OWN_SKIP_INTERCEPTOR);
2401 CHECK_EQ(i::LookupIterator::ACCESSOR, it.state())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i::LookupIterator
::ACCESSOR), (it.state()), "i::LookupIterator::ACCESSOR" " " "=="
" " "it.state()")) { V8_Fatal("../test/cctest/test-api.cc", 2401
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
2402 CHECK(it.GetAccessors()->IsAccessorInfo())do { if ((__builtin_expect(!!(!(it.GetAccessors()->IsAccessorInfo
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2402, "Check failed: %s."
, "it.GetAccessors()->IsAccessorInfo()"); } } while (0)
;
2403}
2404
2405
2406THREADED_TEST(UndefinedIsNotEnumerable)static void TestUndefinedIsNotEnumerable(); RegisterThreadedTest
register_UndefinedIsNotEnumerable(TestUndefinedIsNotEnumerable
, "UndefinedIsNotEnumerable"); static void TestUndefinedIsNotEnumerable
(); CcTest register_test_UndefinedIsNotEnumerable(TestUndefinedIsNotEnumerable
, "../test/cctest/test-api.cc", "UndefinedIsNotEnumerable", __null
, true, true); static void TestUndefinedIsNotEnumerable()
{
2407 LocalContext env;
2408 v8::HandleScope scope(env->GetIsolate());
2409 v8::Local<Value> result = CompileRun("this.propertyIsEnumerable(undefined)");
2410 CHECK(result->IsFalse())do { if ((__builtin_expect(!!(!(result->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2410, "Check failed: %s."
, "result->IsFalse()"); } } while (0)
;
2411}
2412
2413
2414v8::Local<Script> call_recursively_script;
2415static const int kTargetRecursionDepth = 150; // near maximum
2416
2417
2418static void CallScriptRecursivelyCall(
2419 const v8::FunctionCallbackInfo<v8::Value>& args) {
2420 ApiTestFuzzer::Fuzz();
2421 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
2422 int depth = args.This()
2423 ->Get(context, v8_str("depth"))
2424 .ToLocalChecked()
2425 ->Int32Value(context)
2426 .FromJust();
2427 if (depth == kTargetRecursionDepth) return;
2428 CHECK(args.This()do { if ((__builtin_expect(!!(!(args.This() ->Set(context,
v8_str("depth"), v8::Integer::New(args.GetIsolate(), depth +
1)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2431, "Check failed: %s.", "args.This() ->Set(context, v8_str(\"depth\"), v8::Integer::New(args.GetIsolate(), depth + 1)) .FromJust()"
); } } while (0)
2429 ->Set(context, v8_str("depth"),do { if ((__builtin_expect(!!(!(args.This() ->Set(context,
v8_str("depth"), v8::Integer::New(args.GetIsolate(), depth +
1)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2431, "Check failed: %s.", "args.This() ->Set(context, v8_str(\"depth\"), v8::Integer::New(args.GetIsolate(), depth + 1)) .FromJust()"
); } } while (0)
2430 v8::Integer::New(args.GetIsolate(), depth + 1))do { if ((__builtin_expect(!!(!(args.This() ->Set(context,
v8_str("depth"), v8::Integer::New(args.GetIsolate(), depth +
1)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2431, "Check failed: %s.", "args.This() ->Set(context, v8_str(\"depth\"), v8::Integer::New(args.GetIsolate(), depth + 1)) .FromJust()"
); } } while (0)
2431 .FromJust())do { if ((__builtin_expect(!!(!(args.This() ->Set(context,
v8_str("depth"), v8::Integer::New(args.GetIsolate(), depth +
1)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2431, "Check failed: %s.", "args.This() ->Set(context, v8_str(\"depth\"), v8::Integer::New(args.GetIsolate(), depth + 1)) .FromJust()"
); } } while (0)
;
2432 args.GetReturnValue().Set(
2433 call_recursively_script->Run(context).ToLocalChecked());
2434}
2435
2436
2437static void CallFunctionRecursivelyCall(
2438 const v8::FunctionCallbackInfo<v8::Value>& args) {
2439 ApiTestFuzzer::Fuzz();
2440 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
2441 int depth = args.This()
2442 ->Get(context, v8_str("depth"))
2443 .ToLocalChecked()
2444 ->Int32Value(context)
2445 .FromJust();
2446 if (depth == kTargetRecursionDepth) {
2447 printf("[depth = %d]\n", depth);
2448 return;
2449 }
2450 CHECK(args.This()do { if ((__builtin_expect(!!(!(args.This() ->Set(context,
v8_str("depth"), v8::Integer::New(args.GetIsolate(), depth +
1)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2453, "Check failed: %s.", "args.This() ->Set(context, v8_str(\"depth\"), v8::Integer::New(args.GetIsolate(), depth + 1)) .FromJust()"
); } } while (0)
2451 ->Set(context, v8_str("depth"),do { if ((__builtin_expect(!!(!(args.This() ->Set(context,
v8_str("depth"), v8::Integer::New(args.GetIsolate(), depth +
1)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2453, "Check failed: %s.", "args.This() ->Set(context, v8_str(\"depth\"), v8::Integer::New(args.GetIsolate(), depth + 1)) .FromJust()"
); } } while (0)
2452 v8::Integer::New(args.GetIsolate(), depth + 1))do { if ((__builtin_expect(!!(!(args.This() ->Set(context,
v8_str("depth"), v8::Integer::New(args.GetIsolate(), depth +
1)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2453, "Check failed: %s.", "args.This() ->Set(context, v8_str(\"depth\"), v8::Integer::New(args.GetIsolate(), depth + 1)) .FromJust()"
); } } while (0)
2453 .FromJust())do { if ((__builtin_expect(!!(!(args.This() ->Set(context,
v8_str("depth"), v8::Integer::New(args.GetIsolate(), depth +
1)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2453, "Check failed: %s.", "args.This() ->Set(context, v8_str(\"depth\"), v8::Integer::New(args.GetIsolate(), depth + 1)) .FromJust()"
); } } while (0)
;
2454 v8::Local<Value> function =
2455 args.This()
2456 ->Get(context, v8_str("callFunctionRecursively"))
2457 .ToLocalChecked();
2458 args.GetReturnValue().Set(function.As<Function>()
2459 ->Call(context, args.This(), 0, NULL__null)
2460 .ToLocalChecked());
2461}
2462
2463
2464THREADED_TEST(DeepCrossLanguageRecursion)static void TestDeepCrossLanguageRecursion(); RegisterThreadedTest
register_DeepCrossLanguageRecursion(TestDeepCrossLanguageRecursion
, "DeepCrossLanguageRecursion"); static void TestDeepCrossLanguageRecursion
(); CcTest register_test_DeepCrossLanguageRecursion(TestDeepCrossLanguageRecursion
, "../test/cctest/test-api.cc", "DeepCrossLanguageRecursion",
__null, true, true); static void TestDeepCrossLanguageRecursion
()
{
2465 v8::Isolate* isolate = CcTest::isolate();
2466 v8::HandleScope scope(isolate);
2467 v8::Local<v8::ObjectTemplate> global = ObjectTemplate::New(isolate);
2468 global->Set(v8_str("callScriptRecursively"),
2469 v8::FunctionTemplate::New(isolate, CallScriptRecursivelyCall));
2470 global->Set(v8_str("callFunctionRecursively"),
2471 v8::FunctionTemplate::New(isolate, CallFunctionRecursivelyCall));
2472 LocalContext env(NULL__null, global);
2473
2474 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("depth"), v8::Integer::New(isolate, 0)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2476, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"depth\"), v8::Integer::New(isolate, 0)) .FromJust()"
); } } while (0)
2475 ->Set(env.local(), v8_str("depth"), v8::Integer::New(isolate, 0))do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("depth"), v8::Integer::New(isolate, 0)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2476, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"depth\"), v8::Integer::New(isolate, 0)) .FromJust()"
); } } while (0)
2476 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("depth"), v8::Integer::New(isolate, 0)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2476, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"depth\"), v8::Integer::New(isolate, 0)) .FromJust()"
); } } while (0)
;
2477 call_recursively_script = v8_compile("callScriptRecursively()");
2478 call_recursively_script->Run(env.local()).ToLocalChecked();
2479 call_recursively_script = v8::Local<Script>();
2480
2481 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("depth"), v8::Integer::New(isolate, 0)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2483, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"depth\"), v8::Integer::New(isolate, 0)) .FromJust()"
); } } while (0)
2482 ->Set(env.local(), v8_str("depth"), v8::Integer::New(isolate, 0))do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("depth"), v8::Integer::New(isolate, 0)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2483, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"depth\"), v8::Integer::New(isolate, 0)) .FromJust()"
); } } while (0)
2483 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("depth"), v8::Integer::New(isolate, 0)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2483, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"depth\"), v8::Integer::New(isolate, 0)) .FromJust()"
); } } while (0)
;
2484 CompileRun("callFunctionRecursively()");
2485}
2486
2487
2488static void ThrowingPropertyHandlerGet(
2489 Local<Name> key, const v8::PropertyCallbackInfo<v8::Value>& info) {
2490 // Since this interceptor is used on "with" objects, the runtime will look up
2491 // @@unscopables. Punt.
2492 if (key->IsSymbol()) return;
2493 ApiTestFuzzer::Fuzz();
2494 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key));
2495}
2496
2497
2498static void ThrowingPropertyHandlerSet(
2499 Local<Name> key, Local<Value>,
2500 const v8::PropertyCallbackInfo<v8::Value>& info) {
2501 info.GetIsolate()->ThrowException(key);
2502 info.GetReturnValue().SetUndefined(); // not the same as empty handle
2503}
2504
2505
2506THREADED_TEST(CallbackExceptionRegression)static void TestCallbackExceptionRegression(); RegisterThreadedTest
register_CallbackExceptionRegression(TestCallbackExceptionRegression
, "CallbackExceptionRegression"); static void TestCallbackExceptionRegression
(); CcTest register_test_CallbackExceptionRegression(TestCallbackExceptionRegression
, "../test/cctest/test-api.cc", "CallbackExceptionRegression"
, __null, true, true); static void TestCallbackExceptionRegression
()
{
2507 v8::Isolate* isolate = CcTest::isolate();
2508 v8::HandleScope scope(isolate);
2509 v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
2510 obj->SetHandler(v8::NamedPropertyHandlerConfiguration(
2511 ThrowingPropertyHandlerGet, ThrowingPropertyHandlerSet));
2512 LocalContext env;
2513 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), obj->NewInstance(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2516, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), obj->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2514 ->Set(env.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), obj->NewInstance(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2516, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), obj->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2515 obj->NewInstance(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), obj->NewInstance(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2516, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), obj->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2516 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("obj"), obj->NewInstance(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2516, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"obj\"), obj->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
2517 v8::Local<Value> otto =
2518 CompileRun("try { with (obj) { otto; } } catch (e) { e; }");
2519 CHECK(v8_str("otto")->Equals(env.local(), otto).FromJust())do { if ((__builtin_expect(!!(!(v8_str("otto")->Equals(env
.local(), otto).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2519, "Check failed: %s.", "v8_str(\"otto\")->Equals(env.local(), otto).FromJust()"
); } } while (0)
;
2520 v8::Local<Value> netto =
2521 CompileRun("try { with (obj) { netto = 4; } } catch (e) { e; }");
2522 CHECK(v8_str("netto")->Equals(env.local(), netto).FromJust())do { if ((__builtin_expect(!!(!(v8_str("netto")->Equals(env
.local(), netto).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2522, "Check failed: %s.", "v8_str(\"netto\")->Equals(env.local(), netto).FromJust()"
); } } while (0)
;
2523}
2524
2525
2526THREADED_TEST(FunctionPrototype)static void TestFunctionPrototype(); RegisterThreadedTest register_FunctionPrototype
(TestFunctionPrototype, "FunctionPrototype"); static void TestFunctionPrototype
(); CcTest register_test_FunctionPrototype(TestFunctionPrototype
, "../test/cctest/test-api.cc", "FunctionPrototype", __null, true
, true); static void TestFunctionPrototype()
{
2527 v8::Isolate* isolate = CcTest::isolate();
2528 v8::HandleScope scope(isolate);
2529 Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(isolate);
2530 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321));
2531 LocalContext env;
2532 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Foo"), Foo->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2535, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Foo\"), Foo->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2533 ->Set(env.local(), v8_str("Foo"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Foo"), Foo->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2535, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Foo\"), Foo->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2534 Foo->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Foo"), Foo->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2535, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Foo\"), Foo->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
2535 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Foo"), Foo->GetFunction(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2535, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Foo\"), Foo->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
2536 Local<Script> script = v8_compile("Foo.prototype.plak");
2537 CHECK_EQ(v8_run_int32value(script), 321)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8_run_int32value
(script)), (321), "v8_run_int32value(script)" " " "==" " " "321"
)) { V8_Fatal("../test/cctest/test-api.cc", 2537, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2538}
2539
2540
2541THREADED_TEST(InternalFields)static void TestInternalFields(); RegisterThreadedTest register_InternalFields
(TestInternalFields, "InternalFields"); static void TestInternalFields
(); CcTest register_test_InternalFields(TestInternalFields, "../test/cctest/test-api.cc"
, "InternalFields", __null, true, true); static void TestInternalFields
()
{
2542 LocalContext env;
2543 v8::Isolate* isolate = env->GetIsolate();
2544 v8::HandleScope scope(isolate);
2545
2546 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
2547 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
2548 instance_templ->SetInternalFieldCount(1);
2549 Local<v8::Object> obj = templ->GetFunction(env.local())
2550 .ToLocalChecked()
2551 ->NewInstance(env.local())
2552 .ToLocalChecked();
2553 CHECK_EQ(1, obj->InternalFieldCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (obj
->InternalFieldCount()), "1" " " "==" " " "obj->InternalFieldCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2553, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2554 CHECK(obj->GetInternalField(0)->IsUndefined())do { if ((__builtin_expect(!!(!(obj->GetInternalField(0)->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2554, "Check failed: %s.", "obj->GetInternalField(0)->IsUndefined()"
); } } while (0)
;
2555 obj->SetInternalField(0, v8_num(17));
2556 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17), (
obj->GetInternalField(0)->Int32Value(env.local()).FromJust
()), "17" " " "==" " " "obj->GetInternalField(0)->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2556, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2557}
2558
2559
2560THREADED_TEST(GlobalObjectInternalFields)static void TestGlobalObjectInternalFields(); RegisterThreadedTest
register_GlobalObjectInternalFields(TestGlobalObjectInternalFields
, "GlobalObjectInternalFields"); static void TestGlobalObjectInternalFields
(); CcTest register_test_GlobalObjectInternalFields(TestGlobalObjectInternalFields
, "../test/cctest/test-api.cc", "GlobalObjectInternalFields",
__null, true, true); static void TestGlobalObjectInternalFields
()
{
2561 v8::Isolate* isolate = CcTest::isolate();
2562 v8::HandleScope scope(isolate);
2563 Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate);
2564 global_template->SetInternalFieldCount(1);
2565 LocalContext env(NULL__null, global_template);
2566 v8::Local<v8::Object> global_proxy = env->Global();
2567 v8::Local<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
2568 CHECK_EQ(1, global->InternalFieldCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (global
->InternalFieldCount()), "1" " " "==" " " "global->InternalFieldCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2568, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2569 CHECK(global->GetInternalField(0)->IsUndefined())do { if ((__builtin_expect(!!(!(global->GetInternalField(0
)->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2569, "Check failed: %s.", "global->GetInternalField(0)->IsUndefined()"
); } } while (0)
;
2570 global->SetInternalField(0, v8_num(17));
2571 CHECK_EQ(17, global->GetInternalField(0)->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17), (
global->GetInternalField(0)->Int32Value(env.local()).FromJust
()), "17" " " "==" " " "global->GetInternalField(0)->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2571, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2572}
2573
2574
2575THREADED_TEST(GlobalObjectHasRealIndexedProperty)static void TestGlobalObjectHasRealIndexedProperty(); RegisterThreadedTest
register_GlobalObjectHasRealIndexedProperty(TestGlobalObjectHasRealIndexedProperty
, "GlobalObjectHasRealIndexedProperty"); static void TestGlobalObjectHasRealIndexedProperty
(); CcTest register_test_GlobalObjectHasRealIndexedProperty(TestGlobalObjectHasRealIndexedProperty
, "../test/cctest/test-api.cc", "GlobalObjectHasRealIndexedProperty"
, __null, true, true); static void TestGlobalObjectHasRealIndexedProperty
()
{
2576 LocalContext env;
2577 v8::HandleScope scope(CcTest::isolate());
2578
2579 v8::Local<v8::Object> global = env->Global();
2580 CHECK(global->Set(env.local(), 0, v8_str("value")).FromJust())do { if ((__builtin_expect(!!(!(global->Set(env.local(), 0
, v8_str("value")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2580, "Check failed: %s.", "global->Set(env.local(), 0, v8_str(\"value\")).FromJust()"
); } } while (0)
;
2581 CHECK(global->HasRealIndexedProperty(env.local(), 0).FromJust())do { if ((__builtin_expect(!!(!(global->HasRealIndexedProperty
(env.local(), 0).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2581, "Check failed: %s.", "global->HasRealIndexedProperty(env.local(), 0).FromJust()"
); } } while (0)
;
2582}
2583
2584
2585static void CheckAlignedPointerInInternalField(Local<v8::Object> obj,
2586 void* value) {
2587 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(reinterpret_cast<uintptr_t>(value) & 0x1
)), "0" " " "==" " " "static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)"
)) { V8_Fatal("../test/cctest/test-api.cc", 2587, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2588 obj->SetAlignedPointerInInternalField(0, value);
2589 CcTest::heap()->CollectAllGarbage();
2590 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (value)
, (obj->GetAlignedPointerFromInternalField(0)), "value" " "
"==" " " "obj->GetAlignedPointerFromInternalField(0)")) {
V8_Fatal("../test/cctest/test-api.cc", 2590, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2591}
2592
2593
2594THREADED_TEST(InternalFieldsAlignedPointers)static void TestInternalFieldsAlignedPointers(); RegisterThreadedTest
register_InternalFieldsAlignedPointers(TestInternalFieldsAlignedPointers
, "InternalFieldsAlignedPointers"); static void TestInternalFieldsAlignedPointers
(); CcTest register_test_InternalFieldsAlignedPointers(TestInternalFieldsAlignedPointers
, "../test/cctest/test-api.cc", "InternalFieldsAlignedPointers"
, __null, true, true); static void TestInternalFieldsAlignedPointers
()
{
2595 LocalContext env;
2596 v8::Isolate* isolate = env->GetIsolate();
2597 v8::HandleScope scope(isolate);
2598
2599 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
2600 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
2601 instance_templ->SetInternalFieldCount(1);
2602 Local<v8::Object> obj = templ->GetFunction(env.local())
2603 .ToLocalChecked()
2604 ->NewInstance(env.local())
2605 .ToLocalChecked();
2606 CHECK_EQ(1, obj->InternalFieldCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (obj
->InternalFieldCount()), "1" " " "==" " " "obj->InternalFieldCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2606, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2607
2608 CheckAlignedPointerInInternalField(obj, NULL__null);
2609
2610 int* heap_allocated = new int[100];
2611 CheckAlignedPointerInInternalField(obj, heap_allocated);
2612 delete[] heap_allocated;
2613
2614 int stack_allocated[100];
2615 CheckAlignedPointerInInternalField(obj, stack_allocated);
2616
2617 void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1));
2618 CheckAlignedPointerInInternalField(obj, huge);
2619
2620 v8::Global<v8::Object> persistent(isolate, obj);
2621 CHECK_EQ(1, Object::InternalFieldCount(persistent))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (Object
::InternalFieldCount(persistent)), "1" " " "==" " " "Object::InternalFieldCount(persistent)"
)) { V8_Fatal("../test/cctest/test-api.cc", 2621, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2622 CHECK_EQ(huge, Object::GetAlignedPointerFromInternalField(persistent, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (huge),
(Object::GetAlignedPointerFromInternalField(persistent, 0)),
"huge" " " "==" " " "Object::GetAlignedPointerFromInternalField(persistent, 0)"
)) { V8_Fatal("../test/cctest/test-api.cc", 2622, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2623}
2624
2625
2626static void CheckAlignedPointerInEmbedderData(LocalContext* env, int index,
2627 void* value) {
2628 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(reinterpret_cast<uintptr_t>(value) & 0x1
)), "0" " " "==" " " "static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)"
)) { V8_Fatal("../test/cctest/test-api.cc", 2628, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2629 (*env)->SetAlignedPointerInEmbedderData(index, value);
2630 CcTest::heap()->CollectAllGarbage();
2631 CHECK_EQ(value, (*env)->GetAlignedPointerFromEmbedderData(index))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (value)
, ((*env)->GetAlignedPointerFromEmbedderData(index)), "value"
" " "==" " " "(*env)->GetAlignedPointerFromEmbedderData(index)"
)) { V8_Fatal("../test/cctest/test-api.cc", 2631, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2632}
2633
2634
2635static void* AlignedTestPointer(int i) {
2636 return reinterpret_cast<void*>(i * 1234);
2637}
2638
2639
2640THREADED_TEST(EmbedderDataAlignedPointers)static void TestEmbedderDataAlignedPointers(); RegisterThreadedTest
register_EmbedderDataAlignedPointers(TestEmbedderDataAlignedPointers
, "EmbedderDataAlignedPointers"); static void TestEmbedderDataAlignedPointers
(); CcTest register_test_EmbedderDataAlignedPointers(TestEmbedderDataAlignedPointers
, "../test/cctest/test-api.cc", "EmbedderDataAlignedPointers"
, __null, true, true); static void TestEmbedderDataAlignedPointers
()
{
2641 LocalContext env;
2642 v8::HandleScope scope(env->GetIsolate());
2643
2644 CheckAlignedPointerInEmbedderData(&env, 0, NULL__null);
2645
2646 int* heap_allocated = new int[100];
2647 CheckAlignedPointerInEmbedderData(&env, 1, heap_allocated);
2648 delete[] heap_allocated;
2649
2650 int stack_allocated[100];
2651 CheckAlignedPointerInEmbedderData(&env, 2, stack_allocated);
2652
2653 void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1));
2654 CheckAlignedPointerInEmbedderData(&env, 3, huge);
2655
2656 // Test growing of the embedder data's backing store.
2657 for (int i = 0; i < 100; i++) {
2658 env->SetAlignedPointerInEmbedderData(i, AlignedTestPointer(i));
2659 }
2660 CcTest::heap()->CollectAllGarbage();
2661 for (int i = 0; i < 100; i++) {
2662 CHECK_EQ(AlignedTestPointer(i), env->GetAlignedPointerFromEmbedderData(i))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (AlignedTestPointer
(i)), (env->GetAlignedPointerFromEmbedderData(i)), "AlignedTestPointer(i)"
" " "==" " " "env->GetAlignedPointerFromEmbedderData(i)")
) { V8_Fatal("../test/cctest/test-api.cc", 2662, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2663 }
2664}
2665
2666
2667static void CheckEmbedderData(LocalContext* env, int index,
2668 v8::Local<Value> data) {
2669 (*env)->SetEmbedderData(index, data);
2670 CHECK((*env)->GetEmbedderData(index)->StrictEquals(data))do { if ((__builtin_expect(!!(!((*env)->GetEmbedderData(index
)->StrictEquals(data))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2670, "Check failed: %s.", "(*env)->GetEmbedderData(index)->StrictEquals(data)"
); } } while (0)
;
2671}
2672
2673
2674THREADED_TEST(EmbedderData)static void TestEmbedderData(); RegisterThreadedTest register_EmbedderData
(TestEmbedderData, "EmbedderData"); static void TestEmbedderData
(); CcTest register_test_EmbedderData(TestEmbedderData, "../test/cctest/test-api.cc"
, "EmbedderData", __null, true, true); static void TestEmbedderData
()
{
2675 LocalContext env;
2676 v8::Isolate* isolate = env->GetIsolate();
2677 v8::HandleScope scope(isolate);
2678
2679 CheckEmbedderData(&env, 3, v8_str("The quick brown fox jumps"));
2680 CheckEmbedderData(&env, 2, v8_str("over the lazy dog."));
2681 CheckEmbedderData(&env, 1, v8::Number::New(isolate, 1.2345));
2682 CheckEmbedderData(&env, 0, v8::Boolean::New(isolate, true));
2683}
2684
2685
2686THREADED_TEST(IdentityHash)static void TestIdentityHash(); RegisterThreadedTest register_IdentityHash
(TestIdentityHash, "IdentityHash"); static void TestIdentityHash
(); CcTest register_test_IdentityHash(TestIdentityHash, "../test/cctest/test-api.cc"
, "IdentityHash", __null, true, true); static void TestIdentityHash
()
{
2687 LocalContext env;
2688 v8::Isolate* isolate = env->GetIsolate();
2689 v8::HandleScope scope(isolate);
2690
2691 // Ensure that the test starts with an fresh heap to test whether the hash
2692 // code is based on the address.
2693 CcTest::heap()->CollectAllGarbage();
2694 Local<v8::Object> obj = v8::Object::New(isolate);
2695 int hash = obj->GetIdentityHash();
2696 int hash1 = obj->GetIdentityHash();
2697 CHECK_EQ(hash, hash1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash1), "hash" " " "==" " " "hash1")) { V8_Fatal("../test/cctest/test-api.cc"
, 2697, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2698 int hash2 = v8::Object::New(isolate)->GetIdentityHash();
2699 // Since the identity hash is essentially a random number two consecutive
2700 // objects should not be assigned the same hash code. If the test below fails
2701 // the random number generator should be evaluated.
2702 CHECK_NE(hash, hash2)do { if (std::string* _msg = ::v8::base::CheckNEImpl( (hash),
(hash2), "hash" " " "!=" " " "hash2")) { V8_Fatal("../test/cctest/test-api.cc"
, 2702, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2703 CcTest::heap()->CollectAllGarbage();
2704 int hash3 = v8::Object::New(isolate)->GetIdentityHash();
2705 // Make sure that the identity hash is not based on the initial address of
2706 // the object alone. If the test below fails the random number generator
2707 // should be evaluated.
2708 CHECK_NE(hash, hash3)do { if (std::string* _msg = ::v8::base::CheckNEImpl( (hash),
(hash3), "hash" " " "!=" " " "hash3")) { V8_Fatal("../test/cctest/test-api.cc"
, 2708, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2709 int hash4 = obj->GetIdentityHash();
2710 CHECK_EQ(hash, hash4)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash4), "hash" " " "==" " " "hash4")) { V8_Fatal("../test/cctest/test-api.cc"
, 2710, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2711
2712 // Check identity hashes behaviour in the presence of JS accessors.
2713 // Put a getter for 'v8::IdentityHash' on the Object's prototype:
2714 {
2715 CompileRun("Object.prototype['v8::IdentityHash'] = 42;\n");
2716 Local<v8::Object> o1 = v8::Object::New(isolate);
2717 Local<v8::Object> o2 = v8::Object::New(isolate);
2718 CHECK_NE(o1->GetIdentityHash(), o2->GetIdentityHash())do { if (std::string* _msg = ::v8::base::CheckNEImpl( (o1->
GetIdentityHash()), (o2->GetIdentityHash()), "o1->GetIdentityHash()"
" " "!=" " " "o2->GetIdentityHash()")) { V8_Fatal("../test/cctest/test-api.cc"
, 2718, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2719 }
2720 {
2721 CompileRun(
2722 "function cnst() { return 42; };\n"
2723 "Object.prototype.__defineGetter__('v8::IdentityHash', cnst);\n");
2724 Local<v8::Object> o1 = v8::Object::New(isolate);
2725 Local<v8::Object> o2 = v8::Object::New(isolate);
2726 CHECK_NE(o1->GetIdentityHash(), o2->GetIdentityHash())do { if (std::string* _msg = ::v8::base::CheckNEImpl( (o1->
GetIdentityHash()), (o2->GetIdentityHash()), "o1->GetIdentityHash()"
" " "!=" " " "o2->GetIdentityHash()")) { V8_Fatal("../test/cctest/test-api.cc"
, 2726, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2727 }
2728}
2729
2730
2731void GlobalProxyIdentityHash(bool set_in_js) {
2732 LocalContext env;
2733 v8::Isolate* isolate = env->GetIsolate();
2734 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2735 v8::HandleScope scope(isolate);
2736 Local<Object> global_proxy = env->Global();
2737 i::Handle<i::Object> i_global_proxy = v8::Utils::OpenHandle(*global_proxy);
2738 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("global"), global_proxy) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 2740, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"global\"), global_proxy) .FromJust()"
); } } while (0)
2739 ->Set(env.local(), v8_str("global"), global_proxy)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("global"), global_proxy) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 2740, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"global\"), global_proxy) .FromJust()"
); } } while (0)
2740 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("global"), global_proxy) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 2740, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"global\"), global_proxy) .FromJust()"
); } } while (0)
;
2741 i::Handle<i::Object> original_hash;
2742 if (set_in_js) {
2743 CompileRun("var m = new Set(); m.add(global);");
2744 original_hash = i::Handle<i::Object>(i_global_proxy->GetHash(), i_isolate);
2745 } else {
2746 original_hash = i::Handle<i::Object>(
2747 i::Object::GetOrCreateHash(i_isolate, i_global_proxy));
2748 }
2749 CHECK(original_hash->IsSmi())do { if ((__builtin_expect(!!(!(original_hash->IsSmi())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 2749, "Check failed: %s."
, "original_hash->IsSmi()"); } } while (0)
;
2750 int32_t hash1 = i::Handle<i::Smi>::cast(original_hash)->value();
2751 // Hash should be retained after being detached.
2752 env->DetachGlobal();
2753 int hash2 = global_proxy->GetIdentityHash();
2754 CHECK_EQ(hash1, hash2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash1)
, (hash2), "hash1" " " "==" " " "hash2")) { V8_Fatal("../test/cctest/test-api.cc"
, 2754, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2755 {
2756 // Re-attach global proxy to a new context, hash should stay the same.
2757 LocalContext env2(NULL__null, Local<ObjectTemplate>(), global_proxy);
2758 int hash3 = global_proxy->GetIdentityHash();
2759 CHECK_EQ(hash1, hash3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash1)
, (hash3), "hash1" " " "==" " " "hash3")) { V8_Fatal("../test/cctest/test-api.cc"
, 2759, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2760 }
2761}
2762
2763
2764THREADED_TEST(GlobalProxyIdentityHash)static void TestGlobalProxyIdentityHash(); RegisterThreadedTest
register_GlobalProxyIdentityHash(TestGlobalProxyIdentityHash
, "GlobalProxyIdentityHash"); static void TestGlobalProxyIdentityHash
(); CcTest register_test_GlobalProxyIdentityHash(TestGlobalProxyIdentityHash
, "../test/cctest/test-api.cc", "GlobalProxyIdentityHash", __null
, true, true); static void TestGlobalProxyIdentityHash()
{
2765 GlobalProxyIdentityHash(true);
2766 GlobalProxyIdentityHash(false);
2767}
2768
2769
2770TEST(SymbolIdentityHash)static void TestSymbolIdentityHash(); CcTest register_test_SymbolIdentityHash
(TestSymbolIdentityHash, "../test/cctest/test-api.cc", "SymbolIdentityHash"
, __null, true, true); static void TestSymbolIdentityHash()
{
2771 LocalContext env;
2772 v8::Isolate* isolate = env->GetIsolate();
2773 v8::HandleScope scope(isolate);
2774
2775 {
2776 Local<v8::Symbol> symbol = v8::Symbol::New(isolate);
2777 int hash = symbol->GetIdentityHash();
2778 int hash1 = symbol->GetIdentityHash();
2779 CHECK_EQ(hash, hash1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash1), "hash" " " "==" " " "hash1")) { V8_Fatal("../test/cctest/test-api.cc"
, 2779, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2780 CcTest::heap()->CollectAllGarbage();
2781 int hash3 = symbol->GetIdentityHash();
2782 CHECK_EQ(hash, hash3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash3), "hash" " " "==" " " "hash3")) { V8_Fatal("../test/cctest/test-api.cc"
, 2782, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2783 }
2784
2785 {
2786 v8::Local<v8::Symbol> js_symbol =
2787 CompileRun("Symbol('foo')").As<v8::Symbol>();
2788 int hash = js_symbol->GetIdentityHash();
2789 int hash1 = js_symbol->GetIdentityHash();
2790 CHECK_EQ(hash, hash1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash1), "hash" " " "==" " " "hash1")) { V8_Fatal("../test/cctest/test-api.cc"
, 2790, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2791 CcTest::heap()->CollectAllGarbage();
2792 int hash3 = js_symbol->GetIdentityHash();
2793 CHECK_EQ(hash, hash3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash3), "hash" " " "==" " " "hash3")) { V8_Fatal("../test/cctest/test-api.cc"
, 2793, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2794 }
2795}
2796
2797
2798TEST(StringIdentityHash)static void TestStringIdentityHash(); CcTest register_test_StringIdentityHash
(TestStringIdentityHash, "../test/cctest/test-api.cc", "StringIdentityHash"
, __null, true, true); static void TestStringIdentityHash()
{
2799 LocalContext env;
2800 v8::Isolate* isolate = env->GetIsolate();
2801 v8::HandleScope scope(isolate);
2802
2803 Local<v8::String> str = v8_str("str1");
2804 int hash = str->GetIdentityHash();
2805 int hash1 = str->GetIdentityHash();
2806 CHECK_EQ(hash, hash1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash1), "hash" " " "==" " " "hash1")) { V8_Fatal("../test/cctest/test-api.cc"
, 2806, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2807 CcTest::heap()->CollectAllGarbage();
2808 int hash3 = str->GetIdentityHash();
2809 CHECK_EQ(hash, hash3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash3), "hash" " " "==" " " "hash3")) { V8_Fatal("../test/cctest/test-api.cc"
, 2809, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2810
2811 Local<v8::String> str2 = v8_str("str1");
2812 int hash4 = str2->GetIdentityHash();
2813 CHECK_EQ(hash, hash4)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(hash4), "hash" " " "==" " " "hash4")) { V8_Fatal("../test/cctest/test-api.cc"
, 2813, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
2814}
2815
2816
2817THREADED_TEST(SymbolProperties)static void TestSymbolProperties(); RegisterThreadedTest register_SymbolProperties
(TestSymbolProperties, "SymbolProperties"); static void TestSymbolProperties
(); CcTest register_test_SymbolProperties(TestSymbolProperties
, "../test/cctest/test-api.cc", "SymbolProperties", __null, true
, true); static void TestSymbolProperties()
{
2818 LocalContext env;
2819 v8::Isolate* isolate = env->GetIsolate();
2820 v8::HandleScope scope(isolate);
2821
2822 v8::Local<v8::Object> obj = v8::Object::New(isolate);
2823 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate);
2824 v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, v8_str("my-symbol"));
2825 v8::Local<v8::Symbol> sym3 = v8::Symbol::New(isolate, v8_str("sym3"));
2826
2827 CcTest::heap()->CollectAllGarbage();
2828
2829 // Check basic symbol functionality.
2830 CHECK(sym1->IsSymbol())do { if ((__builtin_expect(!!(!(sym1->IsSymbol())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2830, "Check failed: %s."
, "sym1->IsSymbol()"); } } while (0)
;
2831 CHECK(sym2->IsSymbol())do { if ((__builtin_expect(!!(!(sym2->IsSymbol())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2831, "Check failed: %s."
, "sym2->IsSymbol()"); } } while (0)
;
2832 CHECK(!obj->IsSymbol())do { if ((__builtin_expect(!!(!(!obj->IsSymbol())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2832, "Check failed: %s."
, "!obj->IsSymbol()"); } } while (0)
;
2833
2834 CHECK(sym1->Equals(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(sym1->Equals(env.local(), sym1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2834, "Check failed: %s.", "sym1->Equals(env.local(), sym1).FromJust()"
); } } while (0)
;
2835 CHECK(sym2->Equals(env.local(), sym2).FromJust())do { if ((__builtin_expect(!!(!(sym2->Equals(env.local(), sym2
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2835, "Check failed: %s.", "sym2->Equals(env.local(), sym2).FromJust()"
); } } while (0)
;
2836 CHECK(!sym1->Equals(env.local(), sym2).FromJust())do { if ((__builtin_expect(!!(!(!sym1->Equals(env.local(),
sym2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2836, "Check failed: %s.", "!sym1->Equals(env.local(), sym2).FromJust()"
); } } while (0)
;
2837 CHECK(!sym2->Equals(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(!sym2->Equals(env.local(),
sym1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2837, "Check failed: %s.", "!sym2->Equals(env.local(), sym1).FromJust()"
); } } while (0)
;
2838 CHECK(sym1->StrictEquals(sym1))do { if ((__builtin_expect(!!(!(sym1->StrictEquals(sym1)))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 2838, "Check failed: %s."
, "sym1->StrictEquals(sym1)"); } } while (0)
;
2839 CHECK(sym2->StrictEquals(sym2))do { if ((__builtin_expect(!!(!(sym2->StrictEquals(sym2)))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 2839, "Check failed: %s."
, "sym2->StrictEquals(sym2)"); } } while (0)
;
2840 CHECK(!sym1->StrictEquals(sym2))do { if ((__builtin_expect(!!(!(!sym1->StrictEquals(sym2))
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2840, "Check failed: %s."
, "!sym1->StrictEquals(sym2)"); } } while (0)
;
2841 CHECK(!sym2->StrictEquals(sym1))do { if ((__builtin_expect(!!(!(!sym2->StrictEquals(sym1))
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2841, "Check failed: %s."
, "!sym2->StrictEquals(sym1)"); } } while (0)
;
2842
2843 CHECK(sym2->Name()->Equals(env.local(), v8_str("my-symbol")).FromJust())do { if ((__builtin_expect(!!(!(sym2->Name()->Equals(env
.local(), v8_str("my-symbol")).FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 2843, "Check failed: %s.", "sym2->Name()->Equals(env.local(), v8_str(\"my-symbol\")).FromJust()"
); } } while (0)
;
2844
2845 v8::Local<v8::Value> sym_val = sym2;
2846 CHECK(sym_val->IsSymbol())do { if ((__builtin_expect(!!(!(sym_val->IsSymbol())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 2846, "Check failed: %s."
, "sym_val->IsSymbol()"); } } while (0)
;
2847 CHECK(sym_val->Equals(env.local(), sym2).FromJust())do { if ((__builtin_expect(!!(!(sym_val->Equals(env.local(
), sym2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2847, "Check failed: %s.", "sym_val->Equals(env.local(), sym2).FromJust()"
); } } while (0)
;
2848 CHECK(sym_val->StrictEquals(sym2))do { if ((__builtin_expect(!!(!(sym_val->StrictEquals(sym2
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2848, "Check failed: %s."
, "sym_val->StrictEquals(sym2)"); } } while (0)
;
2849 CHECK(v8::Symbol::Cast(*sym_val)->Equals(env.local(), sym2).FromJust())do { if ((__builtin_expect(!!(!(v8::Symbol::Cast(*sym_val)->
Equals(env.local(), sym2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2849, "Check failed: %s.", "v8::Symbol::Cast(*sym_val)->Equals(env.local(), sym2).FromJust()"
); } } while (0)
;
2850
2851 v8::Local<v8::Value> sym_obj = v8::SymbolObject::New(isolate, sym2);
2852 CHECK(sym_obj->IsSymbolObject())do { if ((__builtin_expect(!!(!(sym_obj->IsSymbolObject())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2852, "Check failed: %s."
, "sym_obj->IsSymbolObject()"); } } while (0)
;
2853 CHECK(!sym2->IsSymbolObject())do { if ((__builtin_expect(!!(!(!sym2->IsSymbolObject())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 2853, "Check failed: %s."
, "!sym2->IsSymbolObject()"); } } while (0)
;
2854 CHECK(!obj->IsSymbolObject())do { if ((__builtin_expect(!!(!(!obj->IsSymbolObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 2854, "Check failed: %s."
, "!obj->IsSymbolObject()"); } } while (0)
;
2855 CHECK(sym_obj->Equals(env.local(), sym2).FromJust())do { if ((__builtin_expect(!!(!(sym_obj->Equals(env.local(
), sym2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2855, "Check failed: %s.", "sym_obj->Equals(env.local(), sym2).FromJust()"
); } } while (0)
;
2856 CHECK(!sym_obj->StrictEquals(sym2))do { if ((__builtin_expect(!!(!(!sym_obj->StrictEquals(sym2
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2856, "Check failed: %s."
, "!sym_obj->StrictEquals(sym2)"); } } while (0)
;
2857 CHECK(v8::SymbolObject::Cast(*sym_obj)do { if ((__builtin_expect(!!(!(v8::SymbolObject::Cast(*sym_obj
) ->Equals(env.local(), sym_obj) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2859, "Check failed: %s.", "v8::SymbolObject::Cast(*sym_obj) ->Equals(env.local(), sym_obj) .FromJust()"
); } } while (0)
2858 ->Equals(env.local(), sym_obj)do { if ((__builtin_expect(!!(!(v8::SymbolObject::Cast(*sym_obj
) ->Equals(env.local(), sym_obj) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2859, "Check failed: %s.", "v8::SymbolObject::Cast(*sym_obj) ->Equals(env.local(), sym_obj) .FromJust()"
); } } while (0)
2859 .FromJust())do { if ((__builtin_expect(!!(!(v8::SymbolObject::Cast(*sym_obj
) ->Equals(env.local(), sym_obj) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2859, "Check failed: %s.", "v8::SymbolObject::Cast(*sym_obj) ->Equals(env.local(), sym_obj) .FromJust()"
); } } while (0)
;
2860 CHECK(v8::SymbolObject::Cast(*sym_obj)do { if ((__builtin_expect(!!(!(v8::SymbolObject::Cast(*sym_obj
) ->ValueOf() ->Equals(env.local(), sym2) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 2863, "Check failed: %s."
, "v8::SymbolObject::Cast(*sym_obj) ->ValueOf() ->Equals(env.local(), sym2) .FromJust()"
); } } while (0)
2861 ->ValueOf()do { if ((__builtin_expect(!!(!(v8::SymbolObject::Cast(*sym_obj
) ->ValueOf() ->Equals(env.local(), sym2) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 2863, "Check failed: %s."
, "v8::SymbolObject::Cast(*sym_obj) ->ValueOf() ->Equals(env.local(), sym2) .FromJust()"
); } } while (0)
2862 ->Equals(env.local(), sym2)do { if ((__builtin_expect(!!(!(v8::SymbolObject::Cast(*sym_obj
) ->ValueOf() ->Equals(env.local(), sym2) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 2863, "Check failed: %s."
, "v8::SymbolObject::Cast(*sym_obj) ->ValueOf() ->Equals(env.local(), sym2) .FromJust()"
); } } while (0)
2863 .FromJust())do { if ((__builtin_expect(!!(!(v8::SymbolObject::Cast(*sym_obj
) ->ValueOf() ->Equals(env.local(), sym2) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 2863, "Check failed: %s."
, "v8::SymbolObject::Cast(*sym_obj) ->ValueOf() ->Equals(env.local(), sym2) .FromJust()"
); } } while (0)
;
2864
2865 // Make sure delete of a non-existent symbol property works.
2866 CHECK(obj->Delete(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(obj->Delete(env.local(), sym1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2866, "Check failed: %s.", "obj->Delete(env.local(), sym1).FromJust()"
); } } while (0)
;
2867 CHECK(!obj->Has(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(!obj->Has(env.local(), sym1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2867, "Check failed: %s.", "!obj->Has(env.local(), sym1).FromJust()"
); } } while (0)
;
2868
2869 CHECK(do { if ((__builtin_expect(!!(!(obj->Set(env.local(), sym1
, v8::Integer::New(isolate, 1503)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2870, "Check failed: %s.", "obj->Set(env.local(), sym1, v8::Integer::New(isolate, 1503)).FromJust()"
); } } while (0)
2870 obj->Set(env.local(), sym1, v8::Integer::New(isolate, 1503)).FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), sym1
, v8::Integer::New(isolate, 1503)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2870, "Check failed: %s.", "obj->Set(env.local(), sym1, v8::Integer::New(isolate, 1503)).FromJust()"
); } } while (0)
;
2871 CHECK(obj->Has(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), sym1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2871, "Check failed: %s.", "obj->Has(env.local(), sym1).FromJust()"
); } } while (0)
;
2872 CHECK_EQ(1503, obj->Get(env.local(), sym1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "1503" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2875, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2873 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "1503" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2875, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2874 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "1503" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2875, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2875 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "1503" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2875, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2876 CHECK(do { if ((__builtin_expect(!!(!(obj->Set(env.local(), sym1
, v8::Integer::New(isolate, 2002)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2877, "Check failed: %s.", "obj->Set(env.local(), sym1, v8::Integer::New(isolate, 2002)).FromJust()"
); } } while (0)
2877 obj->Set(env.local(), sym1, v8::Integer::New(isolate, 2002)).FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), sym1
, v8::Integer::New(isolate, 2002)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2877, "Check failed: %s.", "obj->Set(env.local(), sym1, v8::Integer::New(isolate, 2002)).FromJust()"
); } } while (0)
;
2878 CHECK(obj->Has(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), sym1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2878, "Check failed: %s.", "obj->Has(env.local(), sym1).FromJust()"
); } } while (0)
;
2879 CHECK_EQ(2002, obj->Get(env.local(), sym1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2882, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2880 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2882, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2881 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2882, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2882 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2882, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2883 CHECK_EQ(v8::None, obj->GetPropertyAttributes(env.local(), sym1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (obj->GetPropertyAttributes(env.local(), sym1).FromJust
()), "v8::None" " " "==" " " "obj->GetPropertyAttributes(env.local(), sym1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2883, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2884
2885 CHECK_EQ(0u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2886, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2886 obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2886, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2887 unsigned num_props =
2888 obj->GetPropertyNames(env.local()).ToLocalChecked()->Length();
2889 CHECK(obj->Set(env.local(), v8_str("bla"), v8::Integer::New(isolate, 20))do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8_str
("bla"), v8::Integer::New(isolate, 20)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2890, "Check failed: %s."
, "obj->Set(env.local(), v8_str(\"bla\"), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
2890 .FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8_str
("bla"), v8::Integer::New(isolate, 20)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 2890, "Check failed: %s."
, "obj->Set(env.local(), v8_str(\"bla\"), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
;
2891 CHECK_EQ(1u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2892, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2892 obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2892, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2893 CHECK_EQ(num_props + 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (num_props
+ 1), (obj->GetPropertyNames(env.local()).ToLocalChecked(
)->Length()), "num_props + 1" " " "==" " " "obj->GetPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2894, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2894 obj->GetPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (num_props
+ 1), (obj->GetPropertyNames(env.local()).ToLocalChecked(
)->Length()), "num_props + 1" " " "==" " " "obj->GetPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2894, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2895
2896 CcTest::heap()->CollectAllGarbage();
2897
2898 CHECK(obj->SetAccessor(env.local(), sym3, SymbolAccessorGetter,do { if ((__builtin_expect(!!(!(obj->SetAccessor(env.local
(), sym3, SymbolAccessorGetter, SymbolAccessorSetter) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2900, "Check failed: %s."
, "obj->SetAccessor(env.local(), sym3, SymbolAccessorGetter, SymbolAccessorSetter) .FromJust()"
); } } while (0)
2899 SymbolAccessorSetter)do { if ((__builtin_expect(!!(!(obj->SetAccessor(env.local
(), sym3, SymbolAccessorGetter, SymbolAccessorSetter) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2900, "Check failed: %s."
, "obj->SetAccessor(env.local(), sym3, SymbolAccessorGetter, SymbolAccessorSetter) .FromJust()"
); } } while (0)
2900 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetAccessor(env.local
(), sym3, SymbolAccessorGetter, SymbolAccessorSetter) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 2900, "Check failed: %s."
, "obj->SetAccessor(env.local(), sym3, SymbolAccessorGetter, SymbolAccessorSetter) .FromJust()"
); } } while (0)
;
2901 CHECK(obj->Get(env.local(), sym3).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2901, "Check failed: %s.", "obj->Get(env.local(), sym3).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
2902 CHECK(obj->Set(env.local(), sym3, v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), sym3
, v8::Integer::New(isolate, 42)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2902, "Check failed: %s.", "obj->Set(env.local(), sym3, v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
2903 CHECK(obj->Get(env.local(), sym3)do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2906, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2904 .ToLocalChecked()do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2906, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2905 ->Equals(env.local(), v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2906, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2906 .FromJust())do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2906, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
;
2907 CHECK(obj->Get(env.local(), v8_str("accessor_sym3"))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2910, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2908 .ToLocalChecked()do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2910, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2909 ->Equals(env.local(), v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2910, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2910 .FromJust())do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2910, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
;
2911
2912 // Add another property and delete it afterwards to force the object in
2913 // slow case.
2914 CHECK(do { if ((__builtin_expect(!!(!(obj->Set(env.local(), sym2
, v8::Integer::New(isolate, 2008)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2915, "Check failed: %s.", "obj->Set(env.local(), sym2, v8::Integer::New(isolate, 2008)).FromJust()"
); } } while (0)
2915 obj->Set(env.local(), sym2, v8::Integer::New(isolate, 2008)).FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), sym2
, v8::Integer::New(isolate, 2008)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2915, "Check failed: %s.", "obj->Set(env.local(), sym2, v8::Integer::New(isolate, 2008)).FromJust()"
); } } while (0)
;
2916 CHECK_EQ(2002, obj->Get(env.local(), sym1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2919, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2917 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2919, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2918 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2919, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2919 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2919, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2920 CHECK_EQ(2008, obj->Get(env.local(), sym2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->Get(env.local(), sym2) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2008" " " "==" " " "obj->Get(env.local(), sym2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2923, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2921 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->Get(env.local(), sym2) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2008" " " "==" " " "obj->Get(env.local(), sym2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2923, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2922 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->Get(env.local(), sym2) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2008" " " "==" " " "obj->Get(env.local(), sym2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2923, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2923 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->Get(env.local(), sym2) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2008" " " "==" " " "obj->Get(env.local(), sym2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2923, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2924 CHECK_EQ(2002, obj->Get(env.local(), sym1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2927, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2925 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2927, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2926 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2927, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2927 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2927, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2928 CHECK_EQ(2u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "2u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2929, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2929 obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "2u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2929, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2930
2931 CHECK(obj->Has(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), sym1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2931, "Check failed: %s.", "obj->Has(env.local(), sym1).FromJust()"
); } } while (0)
;
2932 CHECK(obj->Has(env.local(), sym2).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), sym2
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2932, "Check failed: %s.", "obj->Has(env.local(), sym2).FromJust()"
); } } while (0)
;
2933 CHECK(obj->Has(env.local(), sym3).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), sym3
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2933, "Check failed: %s.", "obj->Has(env.local(), sym3).FromJust()"
); } } while (0)
;
2934 CHECK(obj->Has(env.local(), v8_str("accessor_sym3")).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), v8_str
("accessor_sym3")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2934, "Check failed: %s.", "obj->Has(env.local(), v8_str(\"accessor_sym3\")).FromJust()"
); } } while (0)
;
2935 CHECK(obj->Delete(env.local(), sym2).FromJust())do { if ((__builtin_expect(!!(!(obj->Delete(env.local(), sym2
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2935, "Check failed: %s.", "obj->Delete(env.local(), sym2).FromJust()"
); } } while (0)
;
2936 CHECK(obj->Has(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), sym1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2936, "Check failed: %s.", "obj->Has(env.local(), sym1).FromJust()"
); } } while (0)
;
2937 CHECK(!obj->Has(env.local(), sym2).FromJust())do { if ((__builtin_expect(!!(!(!obj->Has(env.local(), sym2
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2937, "Check failed: %s.", "!obj->Has(env.local(), sym2).FromJust()"
); } } while (0)
;
2938 CHECK(obj->Has(env.local(), sym3).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), sym3
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2938, "Check failed: %s.", "obj->Has(env.local(), sym3).FromJust()"
); } } while (0)
;
2939 CHECK(obj->Has(env.local(), v8_str("accessor_sym3")).FromJust())do { if ((__builtin_expect(!!(!(obj->Has(env.local(), v8_str
("accessor_sym3")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2939, "Check failed: %s.", "obj->Has(env.local(), v8_str(\"accessor_sym3\")).FromJust()"
); } } while (0)
;
2940 CHECK_EQ(2002, obj->Get(env.local(), sym1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2943, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2941 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2943, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2942 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2943, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2943 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "obj->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2943, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2944 CHECK(obj->Get(env.local(), sym3)do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2947, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2945 .ToLocalChecked()do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2947, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2946 ->Equals(env.local(), v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2947, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2947 .FromJust())do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2947, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
;
2948 CHECK(obj->Get(env.local(), v8_str("accessor_sym3"))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2951, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2949 .ToLocalChecked()do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2951, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2950 ->Equals(env.local(), v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2951, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2951 .FromJust())do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2951, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
;
2952 CHECK_EQ(2u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "2u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2953, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2953 obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "2u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2953, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2954
2955 // Symbol properties are inherited.
2956 v8::Local<v8::Object> child = v8::Object::New(isolate);
2957 CHECK(child->SetPrototype(env.local(), obj).FromJust())do { if ((__builtin_expect(!!(!(child->SetPrototype(env.local
(), obj).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2957, "Check failed: %s.", "child->SetPrototype(env.local(), obj).FromJust()"
); } } while (0)
;
2958 CHECK(child->Has(env.local(), sym1).FromJust())do { if ((__builtin_expect(!!(!(child->Has(env.local(), sym1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
2958, "Check failed: %s.", "child->Has(env.local(), sym1).FromJust()"
); } } while (0)
;
2959 CHECK_EQ(2002, child->Get(env.local(), sym1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(child->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "child->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2962, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2960 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(child->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "child->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2962, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2961 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(child->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "child->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2962, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2962 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(child->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2002" " " "==" " " "child->Get(env.local(), sym1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2962, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2963 CHECK(obj->Get(env.local(), sym3)do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2966, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2964 .ToLocalChecked()do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2966, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2965 ->Equals(env.local(), v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2966, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2966 .FromJust())do { if ((__builtin_expect(!!(!(obj->Get(env.local(), sym3
) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New
(isolate, 42)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2966, "Check failed: %s.", "obj->Get(env.local(), sym3) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
;
2967 CHECK(obj->Get(env.local(), v8_str("accessor_sym3"))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2970, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2968 .ToLocalChecked()do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2970, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2969 ->Equals(env.local(), v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2970, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
2970 .FromJust())do { if ((__builtin_expect(!!(!(obj->Get(env.local(), v8_str
("accessor_sym3")) .ToLocalChecked() ->Equals(env.local(),
v8::Integer::New(isolate, 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2970, "Check failed: %s.", "obj->Get(env.local(), v8_str(\"accessor_sym3\")) .ToLocalChecked() ->Equals(env.local(), v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
;
2971 CHECK_EQ(0u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
child->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2972, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
2972 child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
child->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 2972, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
2973}
2974
2975
2976THREADED_TEST(SymbolTemplateProperties)static void TestSymbolTemplateProperties(); RegisterThreadedTest
register_SymbolTemplateProperties(TestSymbolTemplateProperties
, "SymbolTemplateProperties"); static void TestSymbolTemplateProperties
(); CcTest register_test_SymbolTemplateProperties(TestSymbolTemplateProperties
, "../test/cctest/test-api.cc", "SymbolTemplateProperties", __null
, true, true); static void TestSymbolTemplateProperties()
{
2977 LocalContext env;
2978 v8::Isolate* isolate = env->GetIsolate();
2979 v8::HandleScope scope(isolate);
2980 v8::Local<v8::FunctionTemplate> foo = v8::FunctionTemplate::New(isolate);
2981 v8::Local<v8::Name> name = v8::Symbol::New(isolate);
2982 CHECK(!name.IsEmpty())do { if ((__builtin_expect(!!(!(!name.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 2982, "Check failed: %s.", "!name.IsEmpty()"
); } } while (0)
;
2983 foo->PrototypeTemplate()->Set(name, v8::FunctionTemplate::New(isolate));
2984 v8::Local<v8::Object> new_instance =
2985 foo->InstanceTemplate()->NewInstance(env.local()).ToLocalChecked();
2986 CHECK(!new_instance.IsEmpty())do { if ((__builtin_expect(!!(!(!new_instance.IsEmpty())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 2986, "Check failed: %s."
, "!new_instance.IsEmpty()"); } } while (0)
;
2987 CHECK(new_instance->Has(env.local(), name).FromJust())do { if ((__builtin_expect(!!(!(new_instance->Has(env.local
(), name).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 2987, "Check failed: %s.", "new_instance->Has(env.local(), name).FromJust()"
); } } while (0)
;
2988}
2989
2990
2991THREADED_TEST(PrivatePropertiesOnProxies)static void TestPrivatePropertiesOnProxies(); RegisterThreadedTest
register_PrivatePropertiesOnProxies(TestPrivatePropertiesOnProxies
, "PrivatePropertiesOnProxies"); static void TestPrivatePropertiesOnProxies
(); CcTest register_test_PrivatePropertiesOnProxies(TestPrivatePropertiesOnProxies
, "../test/cctest/test-api.cc", "PrivatePropertiesOnProxies",
__null, true, true); static void TestPrivatePropertiesOnProxies
()
{
2992 i::FLAG_harmony_proxies = true;
2993 LocalContext env;
2994 v8::Isolate* isolate = env->GetIsolate();
2995 v8::HandleScope scope(isolate);
2996
2997 v8::Local<v8::Object> target = CompileRun("({})").As<v8::Object>();
2998 v8::Local<v8::Object> handler = CompileRun("({})").As<v8::Object>();
2999
3000 v8::Local<v8::Proxy> proxy =
3001 v8::Proxy::New(env.local(), target, handler).ToLocalChecked();
3002
3003 v8::Local<v8::Private> priv1 = v8::Private::New(isolate);
3004 v8::Local<v8::Private> priv2 =
3005 v8::Private::New(isolate, v8_str("my-private"));
3006
3007 CcTest::heap()->CollectAllGarbage();
3008
3009 CHECK(priv2->Name()do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3014, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3010 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3014, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3011 v8::String::NewFromUtf8(isolate, "my-private",do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3014, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3012 v8::NewStringType::kNormal)do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3014, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3013 .ToLocalChecked())do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3014, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3014 .FromJust())do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3014, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
3015
3016 // Make sure delete of a non-existent private symbol property works.
3017 proxy->DeletePrivate(env.local(), priv1).FromJust();
3018 CHECK(!proxy->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(!proxy->HasPrivate(env.local
(), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3018, "Check failed: %s.", "!proxy->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3019
3020 CHECK(proxy->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 1503))do { if ((__builtin_expect(!!(!(proxy->SetPrivate(env.local
(), priv1, v8::Integer::New(isolate, 1503)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 3021, "Check failed: %s."
, "proxy->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 1503)) .FromJust()"
); } } while (0)
3021 .FromJust())do { if ((__builtin_expect(!!(!(proxy->SetPrivate(env.local
(), priv1, v8::Integer::New(isolate, 1503)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 3021, "Check failed: %s."
, "proxy->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 1503)) .FromJust()"
); } } while (0)
;
3022 CHECK(proxy->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(proxy->HasPrivate(env.local
(), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3022, "Check failed: %s.", "proxy->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3023 CHECK_EQ(1503, proxy->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3026, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3024 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3026, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3025 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3026, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3026 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3026, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3027 CHECK(proxy->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 2002))do { if ((__builtin_expect(!!(!(proxy->SetPrivate(env.local
(), priv1, v8::Integer::New(isolate, 2002)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 3028, "Check failed: %s."
, "proxy->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 2002)) .FromJust()"
); } } while (0)
3028 .FromJust())do { if ((__builtin_expect(!!(!(proxy->SetPrivate(env.local
(), priv1, v8::Integer::New(isolate, 2002)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 3028, "Check failed: %s."
, "proxy->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 2002)) .FromJust()"
); } } while (0)
;
3029 CHECK(proxy->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(proxy->HasPrivate(env.local
(), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3029, "Check failed: %s.", "proxy->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3030 CHECK_EQ(2002, proxy->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3033, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3031 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3033, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3032 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3033, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3033 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3033, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3034
3035 CHECK_EQ(0u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3036, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3036 proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3036, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3037 unsigned num_props =
3038 proxy->GetPropertyNames(env.local()).ToLocalChecked()->Length();
3039 CHECK(proxy->Set(env.local(), v8::String::NewFromUtf8(do { if ((__builtin_expect(!!(!(proxy->Set(env.local(), v8
::String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3043, "Check failed: %s."
, "proxy->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
3040 isolate, "bla", v8::NewStringType::kNormal)do { if ((__builtin_expect(!!(!(proxy->Set(env.local(), v8
::String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3043, "Check failed: %s."
, "proxy->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
3041 .ToLocalChecked(),do { if ((__builtin_expect(!!(!(proxy->Set(env.local(), v8
::String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3043, "Check failed: %s."
, "proxy->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
3042 v8::Integer::New(isolate, 20))do { if ((__builtin_expect(!!(!(proxy->Set(env.local(), v8
::String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3043, "Check failed: %s."
, "proxy->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
3043 .FromJust())do { if ((__builtin_expect(!!(!(proxy->Set(env.local(), v8
::String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3043, "Check failed: %s."
, "proxy->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
;
3044 CHECK_EQ(1u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3045, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3045 proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3045, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3046 CHECK_EQ(num_props + 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (num_props
+ 1), (proxy->GetPropertyNames(env.local()).ToLocalChecked
()->Length()), "num_props + 1" " " "==" " " "proxy->GetPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3047, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3047 proxy->GetPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (num_props
+ 1), (proxy->GetPropertyNames(env.local()).ToLocalChecked
()->Length()), "num_props + 1" " " "==" " " "proxy->GetPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3047, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3048
3049 CcTest::heap()->CollectAllGarbage();
3050
3051 // Add another property and delete it afterwards to force the object in
3052 // slow case.
3053 CHECK(proxy->SetPrivate(env.local(), priv2, v8::Integer::New(isolate, 2008))do { if ((__builtin_expect(!!(!(proxy->SetPrivate(env.local
(), priv2, v8::Integer::New(isolate, 2008)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 3054, "Check failed: %s."
, "proxy->SetPrivate(env.local(), priv2, v8::Integer::New(isolate, 2008)) .FromJust()"
); } } while (0)
3054 .FromJust())do { if ((__builtin_expect(!!(!(proxy->SetPrivate(env.local
(), priv2, v8::Integer::New(isolate, 2008)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 3054, "Check failed: %s."
, "proxy->SetPrivate(env.local(), priv2, v8::Integer::New(isolate, 2008)) .FromJust()"
); } } while (0)
;
3055 CHECK_EQ(2002, proxy->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3056 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3057 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3058 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3059 CHECK_EQ(2008, proxy->GetPrivate(env.local(), priv2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(proxy->GetPrivate(env.local(), priv2) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "proxy->GetPrivate(env.local(), priv2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3060 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(proxy->GetPrivate(env.local(), priv2) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "proxy->GetPrivate(env.local(), priv2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3061 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(proxy->GetPrivate(env.local(), priv2) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "proxy->GetPrivate(env.local(), priv2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3062 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(proxy->GetPrivate(env.local(), priv2) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "proxy->GetPrivate(env.local(), priv2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3063 CHECK_EQ(2002, proxy->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3066, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3064 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3066, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3065 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3066, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3066 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3066, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3067 CHECK_EQ(1u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3068, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3068 proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3068, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3069
3070 CHECK(proxy->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(proxy->HasPrivate(env.local
(), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3070, "Check failed: %s.", "proxy->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3071 CHECK(proxy->HasPrivate(env.local(), priv2).FromJust())do { if ((__builtin_expect(!!(!(proxy->HasPrivate(env.local
(), priv2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3071, "Check failed: %s.", "proxy->HasPrivate(env.local(), priv2).FromJust()"
); } } while (0)
;
3072 CHECK(proxy->DeletePrivate(env.local(), priv2).FromJust())do { if ((__builtin_expect(!!(!(proxy->DeletePrivate(env.local
(), priv2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3072, "Check failed: %s.", "proxy->DeletePrivate(env.local(), priv2).FromJust()"
); } } while (0)
;
3073 CHECK(proxy->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(proxy->HasPrivate(env.local
(), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3073, "Check failed: %s.", "proxy->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3074 CHECK(!proxy->HasPrivate(env.local(), priv2).FromJust())do { if ((__builtin_expect(!!(!(!proxy->HasPrivate(env.local
(), priv2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3074, "Check failed: %s.", "!proxy->HasPrivate(env.local(), priv2).FromJust()"
); } } while (0)
;
3075 CHECK_EQ(2002, proxy->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3078, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3076 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3078, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3077 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3078, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3078 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "proxy->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3078, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3079 CHECK_EQ(1u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3080, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3080 proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "proxy->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3080, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3081
3082 // Private properties are not inherited (for the time being).
3083 v8::Local<v8::Object> child = v8::Object::New(isolate);
3084 CHECK(child->SetPrototype(env.local(), proxy).FromJust())do { if ((__builtin_expect(!!(!(child->SetPrototype(env.local
(), proxy).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3084, "Check failed: %s.", "child->SetPrototype(env.local(), proxy).FromJust()"
); } } while (0)
;
3085 CHECK(!child->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(!child->HasPrivate(env.local
(), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3085, "Check failed: %s.", "!child->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3086 CHECK_EQ(0u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
child->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3087, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3087 child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
child->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3087, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3088}
3089
3090
3091THREADED_TEST(PrivateProperties)static void TestPrivateProperties(); RegisterThreadedTest register_PrivateProperties
(TestPrivateProperties, "PrivateProperties"); static void TestPrivateProperties
(); CcTest register_test_PrivateProperties(TestPrivateProperties
, "../test/cctest/test-api.cc", "PrivateProperties", __null, true
, true); static void TestPrivateProperties()
{
3092 LocalContext env;
3093 v8::Isolate* isolate = env->GetIsolate();
3094 v8::HandleScope scope(isolate);
3095
3096 v8::Local<v8::Object> obj = v8::Object::New(isolate);
3097 v8::Local<v8::Private> priv1 = v8::Private::New(isolate);
3098 v8::Local<v8::Private> priv2 =
3099 v8::Private::New(isolate, v8_str("my-private"));
3100
3101 CcTest::heap()->CollectAllGarbage();
3102
3103 CHECK(priv2->Name()do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3108, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3104 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3108, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3105 v8::String::NewFromUtf8(isolate, "my-private",do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3108, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3106 v8::NewStringType::kNormal)do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3108, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3107 .ToLocalChecked())do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3108, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
3108 .FromJust())do { if ((__builtin_expect(!!(!(priv2->Name() ->Equals(
env.local(), v8::String::NewFromUtf8(isolate, "my-private", v8
::NewStringType::kNormal) .ToLocalChecked()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3108, "Check failed: %s."
, "priv2->Name() ->Equals(env.local(), v8::String::NewFromUtf8(isolate, \"my-private\", v8::NewStringType::kNormal) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
3109
3110 // Make sure delete of a non-existent private symbol property works.
3111 obj->DeletePrivate(env.local(), priv1).FromJust();
3112 CHECK(!obj->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(!obj->HasPrivate(env.local
(), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3112, "Check failed: %s.", "!obj->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3113
3114 CHECK(obj->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 1503))do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), priv1, v8::Integer::New(isolate, 1503)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 3115, "Check failed: %s."
, "obj->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 1503)) .FromJust()"
); } } while (0)
3115 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), priv1, v8::Integer::New(isolate, 1503)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 3115, "Check failed: %s."
, "obj->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 1503)) .FromJust()"
); } } while (0)
;
3116 CHECK(obj->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(obj->HasPrivate(env.local(
), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3116, "Check failed: %s.", "obj->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3117 CHECK_EQ(1503, obj->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3120, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3118 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3120, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3119 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3120, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3120 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3120, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3121 CHECK(obj->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 2002))do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), priv1, v8::Integer::New(isolate, 2002)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 3122, "Check failed: %s."
, "obj->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 2002)) .FromJust()"
); } } while (0)
3122 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), priv1, v8::Integer::New(isolate, 2002)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 3122, "Check failed: %s."
, "obj->SetPrivate(env.local(), priv1, v8::Integer::New(isolate, 2002)) .FromJust()"
); } } while (0)
;
3123 CHECK(obj->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(obj->HasPrivate(env.local(
), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3123, "Check failed: %s.", "obj->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3124 CHECK_EQ(2002, obj->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3127, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3125 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3127, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3126 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3127, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3127 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3127, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3128
3129 CHECK_EQ(0u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3130, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3130 obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3130, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3131 unsigned num_props =
3132 obj->GetPropertyNames(env.local()).ToLocalChecked()->Length();
3133 CHECK(obj->Set(env.local(), v8::String::NewFromUtf8(do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8::
String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3137, "Check failed: %s."
, "obj->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
3134 isolate, "bla", v8::NewStringType::kNormal)do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8::
String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3137, "Check failed: %s."
, "obj->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
3135 .ToLocalChecked(),do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8::
String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3137, "Check failed: %s."
, "obj->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
3136 v8::Integer::New(isolate, 20))do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8::
String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3137, "Check failed: %s."
, "obj->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
3137 .FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), v8::
String::NewFromUtf8( isolate, "bla", v8::NewStringType::kNormal
) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3137, "Check failed: %s."
, "obj->Set(env.local(), v8::String::NewFromUtf8( isolate, \"bla\", v8::NewStringType::kNormal) .ToLocalChecked(), v8::Integer::New(isolate, 20)) .FromJust()"
); } } while (0)
;
3138 CHECK_EQ(1u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3139, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3139 obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3139, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3140 CHECK_EQ(num_props + 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (num_props
+ 1), (obj->GetPropertyNames(env.local()).ToLocalChecked(
)->Length()), "num_props + 1" " " "==" " " "obj->GetPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3141, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3141 obj->GetPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (num_props
+ 1), (obj->GetPropertyNames(env.local()).ToLocalChecked(
)->Length()), "num_props + 1" " " "==" " " "obj->GetPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3141, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3142
3143 CcTest::heap()->CollectAllGarbage();
3144
3145 // Add another property and delete it afterwards to force the object in
3146 // slow case.
3147 CHECK(obj->SetPrivate(env.local(), priv2, v8::Integer::New(isolate, 2008))do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), priv2, v8::Integer::New(isolate, 2008)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 3148, "Check failed: %s."
, "obj->SetPrivate(env.local(), priv2, v8::Integer::New(isolate, 2008)) .FromJust()"
); } } while (0)
3148 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), priv2, v8::Integer::New(isolate, 2008)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 3148, "Check failed: %s."
, "obj->SetPrivate(env.local(), priv2, v8::Integer::New(isolate, 2008)) .FromJust()"
); } } while (0)
;
3149 CHECK_EQ(2002, obj->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3152, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3150 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3152, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3151 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3152, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3152 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3152, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3153 CHECK_EQ(2008, obj->GetPrivate(env.local(), priv2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->GetPrivate(env.local(), priv2) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "obj->GetPrivate(env.local(), priv2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3156, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3154 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->GetPrivate(env.local(), priv2) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "obj->GetPrivate(env.local(), priv2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3156, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3155 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->GetPrivate(env.local(), priv2) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "obj->GetPrivate(env.local(), priv2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3156, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3156 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->GetPrivate(env.local(), priv2) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "obj->GetPrivate(env.local(), priv2) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3156, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3157 CHECK_EQ(2002, obj->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3160, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3158 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3160, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3159 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3160, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3160 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3160, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3161 CHECK_EQ(1u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3162, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3162 obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3162, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3163
3164 CHECK(obj->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(obj->HasPrivate(env.local(
), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3164, "Check failed: %s.", "obj->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3165 CHECK(obj->HasPrivate(env.local(), priv2).FromJust())do { if ((__builtin_expect(!!(!(obj->HasPrivate(env.local(
), priv2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3165, "Check failed: %s.", "obj->HasPrivate(env.local(), priv2).FromJust()"
); } } while (0)
;
3166 CHECK(obj->DeletePrivate(env.local(), priv2).FromJust())do { if ((__builtin_expect(!!(!(obj->DeletePrivate(env.local
(), priv2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3166, "Check failed: %s.", "obj->DeletePrivate(env.local(), priv2).FromJust()"
); } } while (0)
;
3167 CHECK(obj->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(obj->HasPrivate(env.local(
), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3167, "Check failed: %s.", "obj->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3168 CHECK(!obj->HasPrivate(env.local(), priv2).FromJust())do { if ((__builtin_expect(!!(!(!obj->HasPrivate(env.local
(), priv2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3168, "Check failed: %s.", "!obj->HasPrivate(env.local(), priv2).FromJust()"
); } } while (0)
;
3169 CHECK_EQ(2002, obj->GetPrivate(env.local(), priv1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3172, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3170 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3172, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3171 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3172, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3172 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), priv1) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3172, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3173 CHECK_EQ(1u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3174, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3174 obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "1u" " " "==" " " "obj->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3174, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3175
3176 // Private properties are not inherited (for the time being).
3177 v8::Local<v8::Object> child = v8::Object::New(isolate);
3178 CHECK(child->SetPrototype(env.local(), obj).FromJust())do { if ((__builtin_expect(!!(!(child->SetPrototype(env.local
(), obj).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3178, "Check failed: %s.", "child->SetPrototype(env.local(), obj).FromJust()"
); } } while (0)
;
3179 CHECK(!child->HasPrivate(env.local(), priv1).FromJust())do { if ((__builtin_expect(!!(!(!child->HasPrivate(env.local
(), priv1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3179, "Check failed: %s.", "!child->HasPrivate(env.local(), priv1).FromJust()"
); } } while (0)
;
3180 CHECK_EQ(0u,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
child->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3181, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3181 child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
child->GetOwnPropertyNames(env.local()).ToLocalChecked()->
Length()), "0u" " " "==" " " "child->GetOwnPropertyNames(env.local()).ToLocalChecked()->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3181, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3182}
3183
3184
3185THREADED_TEST(GlobalSymbols)static void TestGlobalSymbols(); RegisterThreadedTest register_GlobalSymbols
(TestGlobalSymbols, "GlobalSymbols"); static void TestGlobalSymbols
(); CcTest register_test_GlobalSymbols(TestGlobalSymbols, "../test/cctest/test-api.cc"
, "GlobalSymbols", __null, true, true); static void TestGlobalSymbols
()
{
3186 LocalContext env;
3187 v8::Isolate* isolate = env->GetIsolate();
3188 v8::HandleScope scope(isolate);
3189
3190 v8::Local<String> name = v8_str("my-symbol");
3191 v8::Local<v8::Symbol> glob = v8::Symbol::For(isolate, name);
3192 v8::Local<v8::Symbol> glob2 = v8::Symbol::For(isolate, name);
3193 CHECK(glob2->SameValue(glob))do { if ((__builtin_expect(!!(!(glob2->SameValue(glob))), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3193, "Check failed: %s."
, "glob2->SameValue(glob)"); } } while (0)
;
3194
3195 v8::Local<v8::Symbol> glob_api = v8::Symbol::ForApi(isolate, name);
3196 v8::Local<v8::Symbol> glob_api2 = v8::Symbol::ForApi(isolate, name);
3197 CHECK(glob_api2->SameValue(glob_api))do { if ((__builtin_expect(!!(!(glob_api2->SameValue(glob_api
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3197, "Check failed: %s."
, "glob_api2->SameValue(glob_api)"); } } while (0)
;
3198 CHECK(!glob_api->SameValue(glob))do { if ((__builtin_expect(!!(!(!glob_api->SameValue(glob)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3198, "Check failed: %s."
, "!glob_api->SameValue(glob)"); } } while (0)
;
3199
3200 v8::Local<v8::Symbol> sym = v8::Symbol::New(isolate, name);
3201 CHECK(!sym->SameValue(glob))do { if ((__builtin_expect(!!(!(!sym->SameValue(glob))), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3201, "Check failed: %s."
, "!sym->SameValue(glob)"); } } while (0)
;
3202
3203 CompileRun("var sym2 = Symbol.for('my-symbol')");
3204 v8::Local<Value> sym2 =
3205 env->Global()->Get(env.local(), v8_str("sym2")).ToLocalChecked();
3206 CHECK(sym2->SameValue(glob))do { if ((__builtin_expect(!!(!(sym2->SameValue(glob))), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 3206, "Check failed: %s."
, "sym2->SameValue(glob)"); } } while (0)
;
3207 CHECK(!sym2->SameValue(glob_api))do { if ((__builtin_expect(!!(!(!sym2->SameValue(glob_api)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3207, "Check failed: %s."
, "!sym2->SameValue(glob_api)"); } } while (0)
;
3208}
3209
3210
3211static void CheckWellKnownSymbol(v8::Local<v8::Symbol>(*getter)(v8::Isolate*),
3212 const char* name) {
3213 LocalContext env;
3214 v8::Isolate* isolate = env->GetIsolate();
3215 v8::HandleScope scope(isolate);
3216
3217 v8::Local<v8::Symbol> symbol = getter(isolate);
3218 std::string script = std::string("var sym = ") + name;
3219 CompileRun(script.c_str());
3220 v8::Local<Value> value =
3221 env->Global()->Get(env.local(), v8_str("sym")).ToLocalChecked();
3222
3223 CHECK(!value.IsEmpty())do { if ((__builtin_expect(!!(!(!value.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3223, "Check failed: %s.", "!value.IsEmpty()"
); } } while (0)
;
3224 CHECK(!symbol.IsEmpty())do { if ((__builtin_expect(!!(!(!symbol.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3224, "Check failed: %s.", "!symbol.IsEmpty()"
); } } while (0)
;
3225 CHECK(value->SameValue(symbol))do { if ((__builtin_expect(!!(!(value->SameValue(symbol)))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 3225, "Check failed: %s."
, "value->SameValue(symbol)"); } } while (0)
;
3226}
3227
3228
3229THREADED_TEST(WellKnownSymbols)static void TestWellKnownSymbols(); RegisterThreadedTest register_WellKnownSymbols
(TestWellKnownSymbols, "WellKnownSymbols"); static void TestWellKnownSymbols
(); CcTest register_test_WellKnownSymbols(TestWellKnownSymbols
, "../test/cctest/test-api.cc", "WellKnownSymbols", __null, true
, true); static void TestWellKnownSymbols()
{
3230 CheckWellKnownSymbol(v8::Symbol::GetIterator, "Symbol.iterator");
3231 CheckWellKnownSymbol(v8::Symbol::GetUnscopables, "Symbol.unscopables");
3232}
3233
3234
3235THREADED_TEST(GlobalPrivates)static void TestGlobalPrivates(); RegisterThreadedTest register_GlobalPrivates
(TestGlobalPrivates, "GlobalPrivates"); static void TestGlobalPrivates
(); CcTest register_test_GlobalPrivates(TestGlobalPrivates, "../test/cctest/test-api.cc"
, "GlobalPrivates", __null, true, true); static void TestGlobalPrivates
()
{
3236 i::FLAG_allow_natives_syntax = true;
3237 LocalContext env;
3238 v8::Isolate* isolate = env->GetIsolate();
3239 v8::HandleScope scope(isolate);
3240
3241 v8::Local<String> name = v8_str("my-private");
3242 v8::Local<v8::Private> glob = v8::Private::ForApi(isolate, name);
3243 v8::Local<v8::Object> obj = v8::Object::New(isolate);
3244 CHECK(obj->SetPrivate(env.local(), glob, v8::Integer::New(isolate, 3))do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), glob, v8::Integer::New(isolate, 3)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3245, "Check failed: %s.", "obj->SetPrivate(env.local(), glob, v8::Integer::New(isolate, 3)) .FromJust()"
); } } while (0)
3245 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), glob, v8::Integer::New(isolate, 3)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3245, "Check failed: %s.", "obj->SetPrivate(env.local(), glob, v8::Integer::New(isolate, 3)) .FromJust()"
); } } while (0)
;
3246
3247 v8::Local<v8::Private> glob2 = v8::Private::ForApi(isolate, name);
3248 CHECK(obj->HasPrivate(env.local(), glob2).FromJust())do { if ((__builtin_expect(!!(!(obj->HasPrivate(env.local(
), glob2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3248, "Check failed: %s.", "obj->HasPrivate(env.local(), glob2).FromJust()"
); } } while (0)
;
3249
3250 v8::Local<v8::Private> priv = v8::Private::New(isolate, name);
3251 CHECK(!obj->HasPrivate(env.local(), priv).FromJust())do { if ((__builtin_expect(!!(!(!obj->HasPrivate(env.local
(), priv).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3251, "Check failed: %s.", "!obj->HasPrivate(env.local(), priv).FromJust()"
); } } while (0)
;
3252
3253 CompileRun("var intern = %CreatePrivateSymbol('my-private')");
3254 v8::Local<Value> intern =
3255 env->Global()->Get(env.local(), v8_str("intern")).ToLocalChecked();
3256 CHECK(!obj->Has(env.local(), intern).FromJust())do { if ((__builtin_expect(!!(!(!obj->Has(env.local(), intern
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
3256, "Check failed: %s.", "!obj->Has(env.local(), intern).FromJust()"
); } } while (0)
;
3257}
3258
3259
3260class ScopedArrayBufferContents {
3261 public:
3262 explicit ScopedArrayBufferContents(const v8::ArrayBuffer::Contents& contents)
3263 : contents_(contents) {}
3264 ~ScopedArrayBufferContents() { free(contents_.Data()); }
3265 void* Data() const { return contents_.Data(); }
3266 size_t ByteLength() const { return contents_.ByteLength(); }
3267
3268 private:
3269 const v8::ArrayBuffer::Contents contents_;
3270};
3271
3272template <typename T>
3273static void CheckInternalFieldsAreZero(v8::Local<T> value) {
3274 CHECK_EQ(T::kInternalFieldCount, value->InternalFieldCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (T::kInternalFieldCount
), (value->InternalFieldCount()), "T::kInternalFieldCount"
" " "==" " " "value->InternalFieldCount()")) { V8_Fatal("../test/cctest/test-api.cc"
, 3274, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3275 for (int i = 0; i < value->InternalFieldCount(); i++) {
3276 CHECK_EQ(0, value->GetInternalField(i)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (value
->GetInternalField(i) ->Int32Value(CcTest::isolate()->
GetCurrentContext()) .FromJust()), "0" " " "==" " " "value->GetInternalField(i) ->Int32Value(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3278, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3277 ->Int32Value(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (value
->GetInternalField(i) ->Int32Value(CcTest::isolate()->
GetCurrentContext()) .FromJust()), "0" " " "==" " " "value->GetInternalField(i) ->Int32Value(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3278, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3278 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (value
->GetInternalField(i) ->Int32Value(CcTest::isolate()->
GetCurrentContext()) .FromJust()), "0" " " "==" " " "value->GetInternalField(i) ->Int32Value(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3278, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3279 }
3280}
3281
3282
3283THREADED_TEST(ArrayBuffer_ApiInternalToExternal)static void TestArrayBuffer_ApiInternalToExternal(); RegisterThreadedTest
register_ArrayBuffer_ApiInternalToExternal(TestArrayBuffer_ApiInternalToExternal
, "ArrayBuffer_ApiInternalToExternal"); static void TestArrayBuffer_ApiInternalToExternal
(); CcTest register_test_ArrayBuffer_ApiInternalToExternal(TestArrayBuffer_ApiInternalToExternal
, "../test/cctest/test-api.cc", "ArrayBuffer_ApiInternalToExternal"
, __null, true, true); static void TestArrayBuffer_ApiInternalToExternal
()
{
3284 LocalContext env;
3285 v8::Isolate* isolate = env->GetIsolate();
3286 v8::HandleScope handle_scope(isolate);
3287
3288 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 1024);
3289 CheckInternalFieldsAreZero(ab);
3290 CHECK_EQ(1024, static_cast<int>(ab->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1024),
(static_cast<int>(ab->ByteLength())), "1024" " " "=="
" " "static_cast<int>(ab->ByteLength())")) { V8_Fatal
("../test/cctest/test-api.cc", 3290, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3291 CHECK(!ab->IsExternal())do { if ((__builtin_expect(!!(!(!ab->IsExternal())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3291, "Check failed: %s."
, "!ab->IsExternal()"); } } while (0)
;
3292 CcTest::heap()->CollectAllGarbage();
3293
3294 ScopedArrayBufferContents ab_contents(ab->Externalize());
3295 CHECK(ab->IsExternal())do { if ((__builtin_expect(!!(!(ab->IsExternal())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3295, "Check failed: %s."
, "ab->IsExternal()"); } } while (0)
;
3296
3297 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1024),
(static_cast<int>(ab_contents.ByteLength())), "1024" " "
"==" " " "static_cast<int>(ab_contents.ByteLength())")
) { V8_Fatal("../test/cctest/test-api.cc", 3297, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3298 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data());
3299 CHECK(data != NULL)do { if ((__builtin_expect(!!(!(data != __null)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3299, "Check failed: %s.", "data != NULL"
); } } while (0)
;
3300 CHECK(env->Global()->Set(env.local(), v8_str("ab"), ab).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("ab"), ab).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3300, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"ab\"), ab).FromJust()"
); } } while (0)
;
3301
3302 v8::Local<v8::Value> result = CompileRun("ab.byteLength");
3303 CHECK_EQ(1024, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1024),
(result->Int32Value(env.local()).FromJust()), "1024" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3303, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3304
3305 result = CompileRun(
3306 "var u8 = new Uint8Array(ab);"
3307 "u8[0] = 0xFF;"
3308 "u8[1] = 0xAA;"
3309 "u8.length");
3310 CHECK_EQ(1024, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1024),
(result->Int32Value(env.local()).FromJust()), "1024" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3310, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3311 CHECK_EQ(0xFF, data[0])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xFF),
(data[0]), "0xFF" " " "==" " " "data[0]")) { V8_Fatal("../test/cctest/test-api.cc"
, 3311, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3312 CHECK_EQ(0xAA, data[1])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xAA),
(data[1]), "0xAA" " " "==" " " "data[1]")) { V8_Fatal("../test/cctest/test-api.cc"
, 3312, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3313 data[0] = 0xCC;
3314 data[1] = 0x11;
3315 result = CompileRun("u8[0] + u8[1]");
3316 CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xDD),
(result->Int32Value(env.local()).FromJust()), "0xDD" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3316, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3317}
3318
3319
3320THREADED_TEST(ArrayBuffer_JSInternalToExternal)static void TestArrayBuffer_JSInternalToExternal(); RegisterThreadedTest
register_ArrayBuffer_JSInternalToExternal(TestArrayBuffer_JSInternalToExternal
, "ArrayBuffer_JSInternalToExternal"); static void TestArrayBuffer_JSInternalToExternal
(); CcTest register_test_ArrayBuffer_JSInternalToExternal(TestArrayBuffer_JSInternalToExternal
, "../test/cctest/test-api.cc", "ArrayBuffer_JSInternalToExternal"
, __null, true, true); static void TestArrayBuffer_JSInternalToExternal
()
{
3321 LocalContext env;
3322 v8::Isolate* isolate = env->GetIsolate();
3323 v8::HandleScope handle_scope(isolate);
3324
3325
3326 v8::Local<v8::Value> result = CompileRun(
3327 "var ab1 = new ArrayBuffer(2);"
3328 "var u8_a = new Uint8Array(ab1);"
3329 "u8_a[0] = 0xAA;"
3330 "u8_a[1] = 0xFF; u8_a.buffer");
3331 Local<v8::ArrayBuffer> ab1 = Local<v8::ArrayBuffer>::Cast(result);
3332 CheckInternalFieldsAreZero(ab1);
3333 CHECK_EQ(2, static_cast<int>(ab1->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>(ab1->ByteLength())), "2" " " "==" " " "static_cast<int>(ab1->ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3333, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3334 CHECK(!ab1->IsExternal())do { if ((__builtin_expect(!!(!(!ab1->IsExternal())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 3334, "Check failed: %s."
, "!ab1->IsExternal()"); } } while (0)
;
3335 ScopedArrayBufferContents ab1_contents(ab1->Externalize());
3336 CHECK(ab1->IsExternal())do { if ((__builtin_expect(!!(!(ab1->IsExternal())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3336, "Check failed: %s."
, "ab1->IsExternal()"); } } while (0)
;
3337
3338 result = CompileRun("ab1.byteLength");
3339 CHECK_EQ(2, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (result
->Int32Value(env.local()).FromJust()), "2" " " "==" " " "result->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3339, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3340 result = CompileRun("u8_a[0]");
3341 CHECK_EQ(0xAA, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xAA),
(result->Int32Value(env.local()).FromJust()), "0xAA" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3341, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3342 result = CompileRun("u8_a[1]");
3343 CHECK_EQ(0xFF, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xFF),
(result->Int32Value(env.local()).FromJust()), "0xFF" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3343, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3344 result = CompileRun(
3345 "var u8_b = new Uint8Array(ab1);"
3346 "u8_b[0] = 0xBB;"
3347 "u8_a[0]");
3348 CHECK_EQ(0xBB, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xBB),
(result->Int32Value(env.local()).FromJust()), "0xBB" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3348, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3349 result = CompileRun("u8_b[1]");
3350 CHECK_EQ(0xFF, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xFF),
(result->Int32Value(env.local()).FromJust()), "0xFF" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3350, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3351
3352 CHECK_EQ(2, static_cast<int>(ab1_contents.ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>(ab1_contents.ByteLength())), "2" " " "==" " " "static_cast<int>(ab1_contents.ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3352, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3353 uint8_t* ab1_data = static_cast<uint8_t*>(ab1_contents.Data());
3354 CHECK_EQ(0xBB, ab1_data[0])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xBB),
(ab1_data[0]), "0xBB" " " "==" " " "ab1_data[0]")) { V8_Fatal
("../test/cctest/test-api.cc", 3354, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3355 CHECK_EQ(0xFF, ab1_data[1])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xFF),
(ab1_data[1]), "0xFF" " " "==" " " "ab1_data[1]")) { V8_Fatal
("../test/cctest/test-api.cc", 3355, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3356 ab1_data[0] = 0xCC;
3357 ab1_data[1] = 0x11;
3358 result = CompileRun("u8_a[0] + u8_a[1]");
3359 CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xDD),
(result->Int32Value(env.local()).FromJust()), "0xDD" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3359, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3360}
3361
3362
3363THREADED_TEST(ArrayBuffer_External)static void TestArrayBuffer_External(); RegisterThreadedTest register_ArrayBuffer_External
(TestArrayBuffer_External, "ArrayBuffer_External"); static void
TestArrayBuffer_External(); CcTest register_test_ArrayBuffer_External
(TestArrayBuffer_External, "../test/cctest/test-api.cc", "ArrayBuffer_External"
, __null, true, true); static void TestArrayBuffer_External()
{
3364 LocalContext env;
3365 v8::Isolate* isolate = env->GetIsolate();
3366 v8::HandleScope handle_scope(isolate);
3367
3368 i::ScopedVector<uint8_t> my_data(100);
3369 memset(my_data.start(), 0, 100);
3370 Local<v8::ArrayBuffer> ab3 =
3371 v8::ArrayBuffer::New(isolate, my_data.start(), 100);
3372 CheckInternalFieldsAreZero(ab3);
3373 CHECK_EQ(100, static_cast<int>(ab3->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (100), (
static_cast<int>(ab3->ByteLength())), "100" " " "=="
" " "static_cast<int>(ab3->ByteLength())")) { V8_Fatal
("../test/cctest/test-api.cc", 3373, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3374 CHECK(ab3->IsExternal())do { if ((__builtin_expect(!!(!(ab3->IsExternal())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3374, "Check failed: %s."
, "ab3->IsExternal()"); } } while (0)
;
3375
3376 CHECK(env->Global()->Set(env.local(), v8_str("ab3"), ab3).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("ab3"), ab3).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3376, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"ab3\"), ab3).FromJust()"
); } } while (0)
;
3377
3378 v8::Local<v8::Value> result = CompileRun("ab3.byteLength");
3379 CHECK_EQ(100, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (100), (
result->Int32Value(env.local()).FromJust()), "100" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3379, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3380
3381 result = CompileRun(
3382 "var u8_b = new Uint8Array(ab3);"
3383 "u8_b[0] = 0xBB;"
3384 "u8_b[1] = 0xCC;"
3385 "u8_b.length");
3386 CHECK_EQ(100, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (100), (
result->Int32Value(env.local()).FromJust()), "100" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3386, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3387 CHECK_EQ(0xBB, my_data[0])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xBB),
(my_data[0]), "0xBB" " " "==" " " "my_data[0]")) { V8_Fatal(
"../test/cctest/test-api.cc", 3387, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3388 CHECK_EQ(0xCC, my_data[1])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xCC),
(my_data[1]), "0xCC" " " "==" " " "my_data[1]")) { V8_Fatal(
"../test/cctest/test-api.cc", 3388, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3389 my_data[0] = 0xCC;
3390 my_data[1] = 0x11;
3391 result = CompileRun("u8_b[0] + u8_b[1]");
3392 CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xDD),
(result->Int32Value(env.local()).FromJust()), "0xDD" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3392, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3393}
3394
3395
3396THREADED_TEST(ArrayBuffer_DisableNeuter)static void TestArrayBuffer_DisableNeuter(); RegisterThreadedTest
register_ArrayBuffer_DisableNeuter(TestArrayBuffer_DisableNeuter
, "ArrayBuffer_DisableNeuter"); static void TestArrayBuffer_DisableNeuter
(); CcTest register_test_ArrayBuffer_DisableNeuter(TestArrayBuffer_DisableNeuter
, "../test/cctest/test-api.cc", "ArrayBuffer_DisableNeuter", __null
, true, true); static void TestArrayBuffer_DisableNeuter()
{
3397 LocalContext env;
3398 v8::Isolate* isolate = env->GetIsolate();
3399 v8::HandleScope handle_scope(isolate);
3400
3401 i::ScopedVector<uint8_t> my_data(100);
3402 memset(my_data.start(), 0, 100);
3403 Local<v8::ArrayBuffer> ab =
3404 v8::ArrayBuffer::New(isolate, my_data.start(), 100);
3405 CHECK(ab->IsNeuterable())do { if ((__builtin_expect(!!(!(ab->IsNeuterable())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 3405, "Check failed: %s."
, "ab->IsNeuterable()"); } } while (0)
;
3406
3407 i::Handle<i::JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
3408 buf->set_is_neuterable(false);
3409
3410 CHECK(!ab->IsNeuterable())do { if ((__builtin_expect(!!(!(!ab->IsNeuterable())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 3410, "Check failed: %s."
, "!ab->IsNeuterable()"); } } while (0)
;
3411}
3412
3413
3414static void CheckDataViewIsNeutered(v8::Local<v8::DataView> dv) {
3415 CHECK_EQ(0, static_cast<int>(dv->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(dv->ByteLength())), "0" " " "==" " " "static_cast<int>(dv->ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3415, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3416 CHECK_EQ(0, static_cast<int>(dv->ByteOffset()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(dv->ByteOffset())), "0" " " "==" " " "static_cast<int>(dv->ByteOffset())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3416, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3417}
3418
3419
3420static void CheckIsNeutered(v8::Local<v8::TypedArray> ta) {
3421 CHECK_EQ(0, static_cast<int>(ta->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(ta->ByteLength())), "0" " " "==" " " "static_cast<int>(ta->ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3421, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3422 CHECK_EQ(0, static_cast<int>(ta->Length()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(ta->Length())), "0" " " "==" " " "static_cast<int>(ta->Length())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3422, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3423 CHECK_EQ(0, static_cast<int>(ta->ByteOffset()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(ta->ByteOffset())), "0" " " "==" " " "static_cast<int>(ta->ByteOffset())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3423, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3424}
3425
3426
3427static void CheckIsTypedArrayVarNeutered(const char* name) {
3428 i::ScopedVector<char> source(1024);
3429 i::SNPrintF(source,
3430 "%s.byteLength == 0 && %s.byteOffset == 0 && %s.length == 0",
3431 name, name, name);
3432 CHECK(CompileRun(source.start())->IsTrue())do { if ((__builtin_expect(!!(!(CompileRun(source.start())->
IsTrue())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3432
, "Check failed: %s.", "CompileRun(source.start())->IsTrue()"
); } } while (0)
;
3433 v8::Local<v8::TypedArray> ta =
3434 v8::Local<v8::TypedArray>::Cast(CompileRun(name));
3435 CheckIsNeutered(ta);
3436}
3437
3438
3439template <typename TypedArray, int kElementSize>
3440static Local<TypedArray> CreateAndCheck(Local<v8::ArrayBuffer> ab,
3441 int byteOffset, int length) {
3442 v8::Local<TypedArray> ta = TypedArray::New(ab, byteOffset, length);
3443 CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta);
3444 CHECK_EQ(byteOffset, static_cast<int>(ta->ByteOffset()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (byteOffset
), (static_cast<int>(ta->ByteOffset())), "byteOffset"
" " "==" " " "static_cast<int>(ta->ByteOffset())"))
{ V8_Fatal("../test/cctest/test-api.cc", 3444, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3445 CHECK_EQ(length, static_cast<int>(ta->Length()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (length
), (static_cast<int>(ta->Length())), "length" " " "=="
" " "static_cast<int>(ta->Length())")) { V8_Fatal("../test/cctest/test-api.cc"
, 3445, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3446 CHECK_EQ(length * kElementSize, static_cast<int>(ta->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (length
* kElementSize), (static_cast<int>(ta->ByteLength()
)), "length * kElementSize" " " "==" " " "static_cast<int>(ta->ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3446, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3447 return ta;
3448}
3449
3450
3451THREADED_TEST(ArrayBuffer_NeuteringApi)static void TestArrayBuffer_NeuteringApi(); RegisterThreadedTest
register_ArrayBuffer_NeuteringApi(TestArrayBuffer_NeuteringApi
, "ArrayBuffer_NeuteringApi"); static void TestArrayBuffer_NeuteringApi
(); CcTest register_test_ArrayBuffer_NeuteringApi(TestArrayBuffer_NeuteringApi
, "../test/cctest/test-api.cc", "ArrayBuffer_NeuteringApi", __null
, true, true); static void TestArrayBuffer_NeuteringApi()
{
3452 LocalContext env;
3453 v8::Isolate* isolate = env->GetIsolate();
3454 v8::HandleScope handle_scope(isolate);
3455
3456 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(isolate, 1024);
3457
3458 v8::Local<v8::Uint8Array> u8a =
3459 CreateAndCheck<v8::Uint8Array, 1>(buffer, 1, 1023);
3460 v8::Local<v8::Uint8ClampedArray> u8c =
3461 CreateAndCheck<v8::Uint8ClampedArray, 1>(buffer, 1, 1023);
3462 v8::Local<v8::Int8Array> i8a =
3463 CreateAndCheck<v8::Int8Array, 1>(buffer, 1, 1023);
3464
3465 v8::Local<v8::Uint16Array> u16a =
3466 CreateAndCheck<v8::Uint16Array, 2>(buffer, 2, 511);
3467 v8::Local<v8::Int16Array> i16a =
3468 CreateAndCheck<v8::Int16Array, 2>(buffer, 2, 511);
3469
3470 v8::Local<v8::Uint32Array> u32a =
3471 CreateAndCheck<v8::Uint32Array, 4>(buffer, 4, 255);
3472 v8::Local<v8::Int32Array> i32a =
3473 CreateAndCheck<v8::Int32Array, 4>(buffer, 4, 255);
3474
3475 v8::Local<v8::Float32Array> f32a =
3476 CreateAndCheck<v8::Float32Array, 4>(buffer, 4, 255);
3477 v8::Local<v8::Float64Array> f64a =
3478 CreateAndCheck<v8::Float64Array, 8>(buffer, 8, 127);
3479
3480 v8::Local<v8::DataView> dv = v8::DataView::New(buffer, 1, 1023);
3481 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv);
3482 CHECK_EQ(1, static_cast<int>(dv->ByteOffset()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (static_cast
<int>(dv->ByteOffset())), "1" " " "==" " " "static_cast<int>(dv->ByteOffset())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3482, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3483 CHECK_EQ(1023, static_cast<int>(dv->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1023),
(static_cast<int>(dv->ByteLength())), "1023" " " "=="
" " "static_cast<int>(dv->ByteLength())")) { V8_Fatal
("../test/cctest/test-api.cc", 3483, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3484
3485 ScopedArrayBufferContents contents(buffer->Externalize());
3486 buffer->Neuter();
3487 CHECK_EQ(0, static_cast<int>(buffer->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(buffer->ByteLength())), "0" " " "==" " " "static_cast<int>(buffer->ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3487, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3488 CheckIsNeutered(u8a);
3489 CheckIsNeutered(u8c);
3490 CheckIsNeutered(i8a);
3491 CheckIsNeutered(u16a);
3492 CheckIsNeutered(i16a);
3493 CheckIsNeutered(u32a);
3494 CheckIsNeutered(i32a);
3495 CheckIsNeutered(f32a);
3496 CheckIsNeutered(f64a);
3497 CheckDataViewIsNeutered(dv);
3498}
3499
3500
3501THREADED_TEST(ArrayBuffer_NeuteringScript)static void TestArrayBuffer_NeuteringScript(); RegisterThreadedTest
register_ArrayBuffer_NeuteringScript(TestArrayBuffer_NeuteringScript
, "ArrayBuffer_NeuteringScript"); static void TestArrayBuffer_NeuteringScript
(); CcTest register_test_ArrayBuffer_NeuteringScript(TestArrayBuffer_NeuteringScript
, "../test/cctest/test-api.cc", "ArrayBuffer_NeuteringScript"
, __null, true, true); static void TestArrayBuffer_NeuteringScript
()
{
3502 LocalContext env;
3503 v8::Isolate* isolate = env->GetIsolate();
3504 v8::HandleScope handle_scope(isolate);
3505
3506 CompileRun(
3507 "var ab = new ArrayBuffer(1024);"
3508 "var u8a = new Uint8Array(ab, 1, 1023);"
3509 "var u8c = new Uint8ClampedArray(ab, 1, 1023);"
3510 "var i8a = new Int8Array(ab, 1, 1023);"
3511 "var u16a = new Uint16Array(ab, 2, 511);"
3512 "var i16a = new Int16Array(ab, 2, 511);"
3513 "var u32a = new Uint32Array(ab, 4, 255);"
3514 "var i32a = new Int32Array(ab, 4, 255);"
3515 "var f32a = new Float32Array(ab, 4, 255);"
3516 "var f64a = new Float64Array(ab, 8, 127);"
3517 "var dv = new DataView(ab, 1, 1023);");
3518
3519 v8::Local<v8::ArrayBuffer> ab =
3520 Local<v8::ArrayBuffer>::Cast(CompileRun("ab"));
3521
3522 v8::Local<v8::DataView> dv = v8::Local<v8::DataView>::Cast(CompileRun("dv"));
3523
3524 ScopedArrayBufferContents contents(ab->Externalize());
3525 ab->Neuter();
3526 CHECK_EQ(0, static_cast<int>(ab->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(ab->ByteLength())), "0" " " "==" " " "static_cast<int>(ab->ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3526, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3527 CHECK_EQ(0, v8_run_int32value(v8_compile("ab.byteLength")))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (v8_run_int32value
(v8_compile("ab.byteLength"))), "0" " " "==" " " "v8_run_int32value(v8_compile(\"ab.byteLength\"))"
)) { V8_Fatal("../test/cctest/test-api.cc", 3527, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3528
3529 CheckIsTypedArrayVarNeutered("u8a");
3530 CheckIsTypedArrayVarNeutered("u8c");
3531 CheckIsTypedArrayVarNeutered("i8a");
3532 CheckIsTypedArrayVarNeutered("u16a");
3533 CheckIsTypedArrayVarNeutered("i16a");
3534 CheckIsTypedArrayVarNeutered("u32a");
3535 CheckIsTypedArrayVarNeutered("i32a");
3536 CheckIsTypedArrayVarNeutered("f32a");
3537 CheckIsTypedArrayVarNeutered("f64a");
3538
3539 CHECK(CompileRun("dv.byteLength == 0 && dv.byteOffset == 0")->IsTrue())do { if ((__builtin_expect(!!(!(CompileRun("dv.byteLength == 0 && dv.byteOffset == 0"
)->IsTrue())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3539, "Check failed: %s.", "CompileRun(\"dv.byteLength == 0 && dv.byteOffset == 0\")->IsTrue()"
); } } while (0)
;
3540 CheckDataViewIsNeutered(dv);
3541}
3542
3543
3544class ScopedSharedArrayBufferContents {
3545 public:
3546 explicit ScopedSharedArrayBufferContents(
3547 const v8::SharedArrayBuffer::Contents& contents)
3548 : contents_(contents) {}
3549 ~ScopedSharedArrayBufferContents() { free(contents_.Data()); }
3550 void* Data() const { return contents_.Data(); }
3551 size_t ByteLength() const { return contents_.ByteLength(); }
3552
3553 private:
3554 const v8::SharedArrayBuffer::Contents contents_;
3555};
3556
3557
3558THREADED_TEST(SharedArrayBuffer_ApiInternalToExternal)static void TestSharedArrayBuffer_ApiInternalToExternal(); RegisterThreadedTest
register_SharedArrayBuffer_ApiInternalToExternal(TestSharedArrayBuffer_ApiInternalToExternal
, "SharedArrayBuffer_ApiInternalToExternal"); static void TestSharedArrayBuffer_ApiInternalToExternal
(); CcTest register_test_SharedArrayBuffer_ApiInternalToExternal
(TestSharedArrayBuffer_ApiInternalToExternal, "../test/cctest/test-api.cc"
, "SharedArrayBuffer_ApiInternalToExternal", __null, true, true
); static void TestSharedArrayBuffer_ApiInternalToExternal()
{
3559 i::FLAG_harmony_sharedarraybuffer = true;
3560 LocalContext env;
3561 v8::Isolate* isolate = env->GetIsolate();
3562 v8::HandleScope handle_scope(isolate);
3563
3564 Local<v8::SharedArrayBuffer> ab = v8::SharedArrayBuffer::New(isolate, 1024);
3565 CheckInternalFieldsAreZero(ab);
3566 CHECK_EQ(1024, static_cast<int>(ab->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1024),
(static_cast<int>(ab->ByteLength())), "1024" " " "=="
" " "static_cast<int>(ab->ByteLength())")) { V8_Fatal
("../test/cctest/test-api.cc", 3566, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3567 CHECK(!ab->IsExternal())do { if ((__builtin_expect(!!(!(!ab->IsExternal())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3567, "Check failed: %s."
, "!ab->IsExternal()"); } } while (0)
;
3568 CcTest::heap()->CollectAllGarbage();
3569
3570 ScopedSharedArrayBufferContents ab_contents(ab->Externalize());
3571 CHECK(ab->IsExternal())do { if ((__builtin_expect(!!(!(ab->IsExternal())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3571, "Check failed: %s."
, "ab->IsExternal()"); } } while (0)
;
3572
3573 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1024),
(static_cast<int>(ab_contents.ByteLength())), "1024" " "
"==" " " "static_cast<int>(ab_contents.ByteLength())")
) { V8_Fatal("../test/cctest/test-api.cc", 3573, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3574 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data());
3575 CHECK(data != NULL)do { if ((__builtin_expect(!!(!(data != __null)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3575, "Check failed: %s.", "data != NULL"
); } } while (0)
;
3576 CHECK(env->Global()->Set(env.local(), v8_str("ab"), ab).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("ab"), ab).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3576, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"ab\"), ab).FromJust()"
); } } while (0)
;
3577
3578 v8::Local<v8::Value> result = CompileRun("ab.byteLength");
3579 CHECK_EQ(1024, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1024),
(result->Int32Value(env.local()).FromJust()), "1024" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3579, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3580
3581 result = CompileRun(
3582 "var u8 = new Uint8Array(ab);"
3583 "u8[0] = 0xFF;"
3584 "u8[1] = 0xAA;"
3585 "u8.length");
3586 CHECK_EQ(1024, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1024),
(result->Int32Value(env.local()).FromJust()), "1024" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3586, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3587 CHECK_EQ(0xFF, data[0])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xFF),
(data[0]), "0xFF" " " "==" " " "data[0]")) { V8_Fatal("../test/cctest/test-api.cc"
, 3587, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3588 CHECK_EQ(0xAA, data[1])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xAA),
(data[1]), "0xAA" " " "==" " " "data[1]")) { V8_Fatal("../test/cctest/test-api.cc"
, 3588, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3589 data[0] = 0xCC;
3590 data[1] = 0x11;
3591 result = CompileRun("u8[0] + u8[1]");
3592 CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xDD),
(result->Int32Value(env.local()).FromJust()), "0xDD" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3592, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3593}
3594
3595
3596THREADED_TEST(SharedArrayBuffer_JSInternalToExternal)static void TestSharedArrayBuffer_JSInternalToExternal(); RegisterThreadedTest
register_SharedArrayBuffer_JSInternalToExternal(TestSharedArrayBuffer_JSInternalToExternal
, "SharedArrayBuffer_JSInternalToExternal"); static void TestSharedArrayBuffer_JSInternalToExternal
(); CcTest register_test_SharedArrayBuffer_JSInternalToExternal
(TestSharedArrayBuffer_JSInternalToExternal, "../test/cctest/test-api.cc"
, "SharedArrayBuffer_JSInternalToExternal", __null, true, true
); static void TestSharedArrayBuffer_JSInternalToExternal()
{
3597 i::FLAG_harmony_sharedarraybuffer = true;
3598 LocalContext env;
3599 v8::Isolate* isolate = env->GetIsolate();
3600 v8::HandleScope handle_scope(isolate);
3601
3602
3603 v8::Local<v8::Value> result = CompileRun(
3604 "var ab1 = new SharedArrayBuffer(2);"
3605 "var u8_a = new Uint8Array(ab1);"
3606 "u8_a[0] = 0xAA;"
3607 "u8_a[1] = 0xFF; u8_a.buffer");
3608 Local<v8::SharedArrayBuffer> ab1 = Local<v8::SharedArrayBuffer>::Cast(result);
3609 CheckInternalFieldsAreZero(ab1);
3610 CHECK_EQ(2, static_cast<int>(ab1->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>(ab1->ByteLength())), "2" " " "==" " " "static_cast<int>(ab1->ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3610, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3611 CHECK(!ab1->IsExternal())do { if ((__builtin_expect(!!(!(!ab1->IsExternal())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 3611, "Check failed: %s."
, "!ab1->IsExternal()"); } } while (0)
;
3612 ScopedSharedArrayBufferContents ab1_contents(ab1->Externalize());
3613 CHECK(ab1->IsExternal())do { if ((__builtin_expect(!!(!(ab1->IsExternal())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3613, "Check failed: %s."
, "ab1->IsExternal()"); } } while (0)
;
3614
3615 result = CompileRun("ab1.byteLength");
3616 CHECK_EQ(2, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (result
->Int32Value(env.local()).FromJust()), "2" " " "==" " " "result->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3616, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3617 result = CompileRun("u8_a[0]");
3618 CHECK_EQ(0xAA, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xAA),
(result->Int32Value(env.local()).FromJust()), "0xAA" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3618, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3619 result = CompileRun("u8_a[1]");
3620 CHECK_EQ(0xFF, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xFF),
(result->Int32Value(env.local()).FromJust()), "0xFF" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3620, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3621 result = CompileRun(
3622 "var u8_b = new Uint8Array(ab1);"
3623 "u8_b[0] = 0xBB;"
3624 "u8_a[0]");
3625 CHECK_EQ(0xBB, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xBB),
(result->Int32Value(env.local()).FromJust()), "0xBB" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3625, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3626 result = CompileRun("u8_b[1]");
3627 CHECK_EQ(0xFF, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xFF),
(result->Int32Value(env.local()).FromJust()), "0xFF" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3627, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3628
3629 CHECK_EQ(2, static_cast<int>(ab1_contents.ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>(ab1_contents.ByteLength())), "2" " " "==" " " "static_cast<int>(ab1_contents.ByteLength())"
)) { V8_Fatal("../test/cctest/test-api.cc", 3629, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3630 uint8_t* ab1_data = static_cast<uint8_t*>(ab1_contents.Data());
3631 CHECK_EQ(0xBB, ab1_data[0])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xBB),
(ab1_data[0]), "0xBB" " " "==" " " "ab1_data[0]")) { V8_Fatal
("../test/cctest/test-api.cc", 3631, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3632 CHECK_EQ(0xFF, ab1_data[1])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xFF),
(ab1_data[1]), "0xFF" " " "==" " " "ab1_data[1]")) { V8_Fatal
("../test/cctest/test-api.cc", 3632, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3633 ab1_data[0] = 0xCC;
3634 ab1_data[1] = 0x11;
3635 result = CompileRun("u8_a[0] + u8_a[1]");
3636 CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xDD),
(result->Int32Value(env.local()).FromJust()), "0xDD" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3636, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3637}
3638
3639
3640THREADED_TEST(SharedArrayBuffer_External)static void TestSharedArrayBuffer_External(); RegisterThreadedTest
register_SharedArrayBuffer_External(TestSharedArrayBuffer_External
, "SharedArrayBuffer_External"); static void TestSharedArrayBuffer_External
(); CcTest register_test_SharedArrayBuffer_External(TestSharedArrayBuffer_External
, "../test/cctest/test-api.cc", "SharedArrayBuffer_External",
__null, true, true); static void TestSharedArrayBuffer_External
()
{
3641 i::FLAG_harmony_sharedarraybuffer = true;
3642 LocalContext env;
3643 v8::Isolate* isolate = env->GetIsolate();
3644 v8::HandleScope handle_scope(isolate);
3645
3646 i::ScopedVector<uint8_t> my_data(100);
3647 memset(my_data.start(), 0, 100);
3648 Local<v8::SharedArrayBuffer> ab3 =
3649 v8::SharedArrayBuffer::New(isolate, my_data.start(), 100);
3650 CheckInternalFieldsAreZero(ab3);
3651 CHECK_EQ(100, static_cast<int>(ab3->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (100), (
static_cast<int>(ab3->ByteLength())), "100" " " "=="
" " "static_cast<int>(ab3->ByteLength())")) { V8_Fatal
("../test/cctest/test-api.cc", 3651, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3652 CHECK(ab3->IsExternal())do { if ((__builtin_expect(!!(!(ab3->IsExternal())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3652, "Check failed: %s."
, "ab3->IsExternal()"); } } while (0)
;
3653
3654 CHECK(env->Global()->Set(env.local(), v8_str("ab3"), ab3).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("ab3"), ab3).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3654, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"ab3\"), ab3).FromJust()"
); } } while (0)
;
3655
3656 v8::Local<v8::Value> result = CompileRun("ab3.byteLength");
3657 CHECK_EQ(100, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (100), (
result->Int32Value(env.local()).FromJust()), "100" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3657, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3658
3659 result = CompileRun(
3660 "var u8_b = new Uint8Array(ab3);"
3661 "u8_b[0] = 0xBB;"
3662 "u8_b[1] = 0xCC;"
3663 "u8_b.length");
3664 CHECK_EQ(100, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (100), (
result->Int32Value(env.local()).FromJust()), "100" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3664, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3665 CHECK_EQ(0xBB, my_data[0])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xBB),
(my_data[0]), "0xBB" " " "==" " " "my_data[0]")) { V8_Fatal(
"../test/cctest/test-api.cc", 3665, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3666 CHECK_EQ(0xCC, my_data[1])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xCC),
(my_data[1]), "0xCC" " " "==" " " "my_data[1]")) { V8_Fatal(
"../test/cctest/test-api.cc", 3666, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3667 my_data[0] = 0xCC;
3668 my_data[1] = 0x11;
3669 result = CompileRun("u8_b[0] + u8_b[1]");
3670 CHECK_EQ(0xDD, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xDD),
(result->Int32Value(env.local()).FromJust()), "0xDD" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 3670, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
3671}
3672
3673
3674THREADED_TEST(HiddenProperties)static void TestHiddenProperties(); RegisterThreadedTest register_HiddenProperties
(TestHiddenProperties, "HiddenProperties"); static void TestHiddenProperties
(); CcTest register_test_HiddenProperties(TestHiddenProperties
, "../test/cctest/test-api.cc", "HiddenProperties", __null, true
, true); static void TestHiddenProperties()
{
3675 LocalContext env;
3676 v8::Isolate* isolate = env->GetIsolate();
3677 v8::HandleScope scope(isolate);
3678
3679 v8::Local<v8::Object> obj = v8::Object::New(env->GetIsolate());
3680 v8::Local<v8::Private> key =
3681 v8::Private::ForApi(isolate, v8_str("api-test::hidden-key"));
3682 v8::Local<v8::String> empty = v8_str("");
3683 v8::Local<v8::String> prop_name = v8_str("prop_name");
3684
3685 CcTest::heap()->CollectAllGarbage();
3686
3687 // Make sure delete of a non-existent hidden value works
3688 obj->DeletePrivate(env.local(), key).FromJust();
3689
3690 CHECK(obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 1503))do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(isolate, 1503)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3691, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 1503)) .FromJust()"
); } } while (0)
3691 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(isolate, 1503)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3691, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 1503)) .FromJust()"
); } } while (0)
;
3692 CHECK_EQ(1503, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3695, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3693 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3695, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3694 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3695, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3695 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "1503" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3695, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3696 CHECK(obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 2002))do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(isolate, 2002)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3697, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 2002)) .FromJust()"
); } } while (0)
3697 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(isolate, 2002)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3697, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 2002)) .FromJust()"
); } } while (0)
;
3698 CHECK_EQ(2002, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3701, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3699 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3701, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3700 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3701, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3701 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3701, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3702
3703 CcTest::heap()->CollectAllGarbage();
3704
3705 // Make sure we do not find the hidden property.
3706 CHECK(!obj->Has(env.local(), empty).FromJust())do { if ((__builtin_expect(!!(!(!obj->Has(env.local(), empty
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
3706, "Check failed: %s.", "!obj->Has(env.local(), empty).FromJust()"
); } } while (0)
;
3707 CHECK_EQ(2002, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3710, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3708 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3710, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3709 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3710, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3710 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3710, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3711 CHECK(obj->Get(env.local(), empty).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(obj->Get(env.local(), empty
).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3711, "Check failed: %s.", "obj->Get(env.local(), empty).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
3712 CHECK_EQ(2002, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3715, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3713 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3715, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3714 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3715, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3715 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3715, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3716 CHECK(do { if ((__builtin_expect(!!(!(obj->Set(env.local(), empty
, v8::Integer::New(isolate, 2003)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3717, "Check failed: %s.", "obj->Set(env.local(), empty, v8::Integer::New(isolate, 2003)).FromJust()"
); } } while (0)
3717 obj->Set(env.local(), empty, v8::Integer::New(isolate, 2003)).FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), empty
, v8::Integer::New(isolate, 2003)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3717, "Check failed: %s.", "obj->Set(env.local(), empty, v8::Integer::New(isolate, 2003)).FromJust()"
); } } while (0)
;
3718 CHECK_EQ(2002, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3721, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3719 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3721, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3720 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3721, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3721 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3721, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3722 CHECK_EQ(2003, obj->Get(env.local(), empty)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2003),
(obj->Get(env.local(), empty) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2003" " " "==" " " "obj->Get(env.local(), empty) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3725, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3723 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2003),
(obj->Get(env.local(), empty) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2003" " " "==" " " "obj->Get(env.local(), empty) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3725, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3724 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2003),
(obj->Get(env.local(), empty) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2003" " " "==" " " "obj->Get(env.local(), empty) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3725, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3725 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2003),
(obj->Get(env.local(), empty) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "2003" " " "==" " " "obj->Get(env.local(), empty) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3725, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3726
3727 CcTest::heap()->CollectAllGarbage();
3728
3729 // Add another property and delete it afterwards to force the object in
3730 // slow case.
3731 CHECK(obj->Set(env.local(), prop_name, v8::Integer::New(isolate, 2008))do { if ((__builtin_expect(!!(!(obj->Set(env.local(), prop_name
, v8::Integer::New(isolate, 2008)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3732, "Check failed: %s.", "obj->Set(env.local(), prop_name, v8::Integer::New(isolate, 2008)) .FromJust()"
); } } while (0)
3732 .FromJust())do { if ((__builtin_expect(!!(!(obj->Set(env.local(), prop_name
, v8::Integer::New(isolate, 2008)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3732, "Check failed: %s.", "obj->Set(env.local(), prop_name, v8::Integer::New(isolate, 2008)) .FromJust()"
); } } while (0)
;
3733 CHECK_EQ(2002, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3736, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3734 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3736, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3735 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3736, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3736 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3736, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3737 CHECK_EQ(2008, obj->Get(env.local(), prop_name)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->Get(env.local(), prop_name) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "obj->Get(env.local(), prop_name) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3740, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3738 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->Get(env.local(), prop_name) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "obj->Get(env.local(), prop_name) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3740, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3739 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->Get(env.local(), prop_name) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "obj->Get(env.local(), prop_name) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3740, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3740 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2008),
(obj->Get(env.local(), prop_name) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2008" " " "==" " " "obj->Get(env.local(), prop_name) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3740, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3741 CHECK_EQ(2002, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3744, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3742 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3744, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3743 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3744, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3744 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3744, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3745 CHECK(obj->Delete(env.local(), prop_name).FromJust())do { if ((__builtin_expect(!!(!(obj->Delete(env.local(), prop_name
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
3745, "Check failed: %s.", "obj->Delete(env.local(), prop_name).FromJust()"
); } } while (0)
;
3746 CHECK_EQ(2002, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3749, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3747 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3749, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3748 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3749, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3749 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2002),
(obj->GetPrivate(env.local(), key) .ToLocalChecked() ->
Int32Value(env.local()) .FromJust()), "2002" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3749, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3750
3751 CcTest::heap()->CollectAllGarbage();
3752
3753 CHECK(obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 2002))do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(isolate, 2002)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3754, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 2002)) .FromJust()"
); } } while (0)
3754 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(isolate, 2002)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3754, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(isolate, 2002)) .FromJust()"
); } } while (0)
;
3755 CHECK(obj->DeletePrivate(env.local(), key).FromJust())do { if ((__builtin_expect(!!(!(obj->DeletePrivate(env.local
(), key).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3755, "Check failed: %s.", "obj->DeletePrivate(env.local(), key).FromJust()"
); } } while (0)
;
3756 CHECK(!obj->HasPrivate(env.local(), key).FromJust())do { if ((__builtin_expect(!!(!(!obj->HasPrivate(env.local
(), key).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3756, "Check failed: %s.", "!obj->HasPrivate(env.local(), key).FromJust()"
); } } while (0)
;
3757}
3758
3759
3760THREADED_TEST(Regress97784)static void TestRegress97784(); RegisterThreadedTest register_Regress97784
(TestRegress97784, "Regress97784"); static void TestRegress97784
(); CcTest register_test_Regress97784(TestRegress97784, "../test/cctest/test-api.cc"
, "Regress97784", __null, true, true); static void TestRegress97784
()
{
3761 // Regression test for crbug.com/97784
3762 // Messing with the Object.prototype should not have effect on
3763 // hidden properties.
3764 LocalContext env;
3765 v8::HandleScope scope(env->GetIsolate());
3766
3767 v8::Local<v8::Object> obj = v8::Object::New(env->GetIsolate());
3768 v8::Local<v8::Private> key =
3769 v8::Private::New(env->GetIsolate(), v8_str("hidden"));
3770
3771 CompileRun(
3772 "set_called = false;"
3773 "Object.defineProperty("
3774 " Object.prototype,"
3775 " 'hidden',"
3776 " {get: function() { return 45; },"
3777 " set: function() { set_called = true; }})");
3778
3779 CHECK(!obj->HasPrivate(env.local(), key).FromJust())do { if ((__builtin_expect(!!(!(!obj->HasPrivate(env.local
(), key).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3779, "Check failed: %s.", "!obj->HasPrivate(env.local(), key).FromJust()"
); } } while (0)
;
3780 // Make sure that the getter and setter from Object.prototype is not invoked.
3781 // If it did we would have full access to the hidden properties in
3782 // the accessor.
3783 CHECK(do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(env->GetIsolate(), 42)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3785, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(env->GetIsolate(), 42)) .FromJust()"
); } } while (0)
3784 obj->SetPrivate(env.local(), key, v8::Integer::New(env->GetIsolate(), 42))do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(env->GetIsolate(), 42)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3785, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(env->GetIsolate(), 42)) .FromJust()"
); } } while (0)
3785 .FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(env.local(
), key, v8::Integer::New(env->GetIsolate(), 42)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 3785, "Check failed: %s."
, "obj->SetPrivate(env.local(), key, v8::Integer::New(env->GetIsolate(), 42)) .FromJust()"
); } } while (0)
;
3786 ExpectFalse("set_called");
3787 CHECK_EQ(42, obj->GetPrivate(env.local(), key)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3790, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3788 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3790, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3789 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3790, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3790 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "obj->GetPrivate(env.local(), key) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 3790, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3791}
3792
3793
3794THREADED_TEST(External)static void TestExternal(); RegisterThreadedTest register_External
(TestExternal, "External"); static void TestExternal(); CcTest
register_test_External(TestExternal, "../test/cctest/test-api.cc"
, "External", __null, true, true); static void TestExternal()
{
3795 v8::HandleScope scope(CcTest::isolate());
3796 int x = 3;
3797 Local<v8::External> ext = v8::External::New(CcTest::isolate(), &x);
3798 LocalContext env;
3799 CHECK(env->Global()->Set(env.local(), v8_str("ext"), ext).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("ext"), ext).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 3799, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"ext\"), ext).FromJust()"
); } } while (0)
;
3800 Local<Value> reext_obj = CompileRun("this.ext");
3801 v8::Local<v8::External> reext = reext_obj.As<v8::External>();
3802 int* ptr = static_cast<int*>(reext->Value());
3803 CHECK_EQ(x, 3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (x), (3
), "x" " " "==" " " "3")) { V8_Fatal("../test/cctest/test-api.cc"
, 3803, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3804 *ptr = 10;
3805 CHECK_EQ(x, 10)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (x), (10
), "x" " " "==" " " "10")) { V8_Fatal("../test/cctest/test-api.cc"
, 3805, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3806
3807 // Make sure unaligned pointers are wrapped properly.
3808 char* data = i::StrDup("0123456789");
3809 Local<v8::Value> zero = v8::External::New(CcTest::isolate(), &data[0]);
3810 Local<v8::Value> one = v8::External::New(CcTest::isolate(), &data[1]);
3811 Local<v8::Value> two = v8::External::New(CcTest::isolate(), &data[2]);
3812 Local<v8::Value> three = v8::External::New(CcTest::isolate(), &data[3]);
3813
3814 char* char_ptr = reinterpret_cast<char*>(v8::External::Cast(*zero)->Value());
3815 CHECK_EQ('0', *char_ptr)do { if (std::string* _msg = ::v8::base::CheckEQImpl( ('0'), (
*char_ptr), "'0'" " " "==" " " "*char_ptr")) { V8_Fatal("../test/cctest/test-api.cc"
, 3815, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3816 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*one)->Value());
3817 CHECK_EQ('1', *char_ptr)do { if (std::string* _msg = ::v8::base::CheckEQImpl( ('1'), (
*char_ptr), "'1'" " " "==" " " "*char_ptr")) { V8_Fatal("../test/cctest/test-api.cc"
, 3817, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3818 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*two)->Value());
3819 CHECK_EQ('2', *char_ptr)do { if (std::string* _msg = ::v8::base::CheckEQImpl( ('2'), (
*char_ptr), "'2'" " " "==" " " "*char_ptr")) { V8_Fatal("../test/cctest/test-api.cc"
, 3819, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3820 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*three)->Value());
3821 CHECK_EQ('3', *char_ptr)do { if (std::string* _msg = ::v8::base::CheckEQImpl( ('3'), (
*char_ptr), "'3'" " " "==" " " "*char_ptr")) { V8_Fatal("../test/cctest/test-api.cc"
, 3821, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3822 i::DeleteArray(data);
3823}
3824
3825
3826THREADED_TEST(GlobalHandle)static void TestGlobalHandle(); RegisterThreadedTest register_GlobalHandle
(TestGlobalHandle, "GlobalHandle"); static void TestGlobalHandle
(); CcTest register_test_GlobalHandle(TestGlobalHandle, "../test/cctest/test-api.cc"
, "GlobalHandle", __null, true, true); static void TestGlobalHandle
()
{
3827 v8::Isolate* isolate = CcTest::isolate();
3828 v8::Persistent<String> global;
3829 {
3830 v8::HandleScope scope(isolate);
3831 global.Reset(isolate, v8_str("str"));
3832 }
3833 {
3834 v8::HandleScope scope(isolate);
3835 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::Local
<String>::New(isolate, global)->Length()), (3), "v8::Local<String>::New(isolate, global)->Length()"
" " "==" " " "3")) { V8_Fatal("../test/cctest/test-api.cc", 3835
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
3836 }
3837 global.Reset();
3838 {
3839 v8::HandleScope scope(isolate);
3840 global.Reset(isolate, v8_str("str"));
3841 }
3842 {
3843 v8::HandleScope scope(isolate);
3844 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::Local
<String>::New(isolate, global)->Length()), (3), "v8::Local<String>::New(isolate, global)->Length()"
" " "==" " " "3")) { V8_Fatal("../test/cctest/test-api.cc", 3844
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
3845 }
3846 global.Reset();
3847}
3848
3849
3850THREADED_TEST(ResettingGlobalHandle)static void TestResettingGlobalHandle(); RegisterThreadedTest
register_ResettingGlobalHandle(TestResettingGlobalHandle, "ResettingGlobalHandle"
); static void TestResettingGlobalHandle(); CcTest register_test_ResettingGlobalHandle
(TestResettingGlobalHandle, "../test/cctest/test-api.cc", "ResettingGlobalHandle"
, __null, true, true); static void TestResettingGlobalHandle(
)
{
3851 v8::Isolate* isolate = CcTest::isolate();
3852 v8::Persistent<String> global;
3853 {
3854 v8::HandleScope scope(isolate);
3855 global.Reset(isolate, v8_str("str"));
3856 }
3857 v8::internal::GlobalHandles* global_handles =
3858 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles();
3859 int initial_handle_count = global_handles->global_handles_count();
3860 {
3861 v8::HandleScope scope(isolate);
3862 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::Local
<String>::New(isolate, global)->Length()), (3), "v8::Local<String>::New(isolate, global)->Length()"
" " "==" " " "3")) { V8_Fatal("../test/cctest/test-api.cc", 3862
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
3863 }
3864 {
3865 v8::HandleScope scope(isolate);
3866 global.Reset(isolate, v8_str("longer"));
3867 }
3868 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global_handles
->global_handles_count()), (initial_handle_count), "global_handles->global_handles_count()"
" " "==" " " "initial_handle_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 3868, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3869 {
3870 v8::HandleScope scope(isolate);
3871 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::Local
<String>::New(isolate, global)->Length()), (6), "v8::Local<String>::New(isolate, global)->Length()"
" " "==" " " "6")) { V8_Fatal("../test/cctest/test-api.cc", 3871
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
3872 }
3873 global.Reset();
3874 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global_handles
->global_handles_count()), (initial_handle_count - 1), "global_handles->global_handles_count()"
" " "==" " " "initial_handle_count - 1")) { V8_Fatal("../test/cctest/test-api.cc"
, 3874, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3875}
3876
3877
3878THREADED_TEST(ResettingGlobalHandleToEmpty)static void TestResettingGlobalHandleToEmpty(); RegisterThreadedTest
register_ResettingGlobalHandleToEmpty(TestResettingGlobalHandleToEmpty
, "ResettingGlobalHandleToEmpty"); static void TestResettingGlobalHandleToEmpty
(); CcTest register_test_ResettingGlobalHandleToEmpty(TestResettingGlobalHandleToEmpty
, "../test/cctest/test-api.cc", "ResettingGlobalHandleToEmpty"
, __null, true, true); static void TestResettingGlobalHandleToEmpty
()
{
3879 v8::Isolate* isolate = CcTest::isolate();
3880 v8::Persistent<String> global;
3881 {
3882 v8::HandleScope scope(isolate);
3883 global.Reset(isolate, v8_str("str"));
3884 }
3885 v8::internal::GlobalHandles* global_handles =
3886 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles();
3887 int initial_handle_count = global_handles->global_handles_count();
3888 {
3889 v8::HandleScope scope(isolate);
3890 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::Local
<String>::New(isolate, global)->Length()), (3), "v8::Local<String>::New(isolate, global)->Length()"
" " "==" " " "3")) { V8_Fatal("../test/cctest/test-api.cc", 3890
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
3891 }
3892 {
3893 v8::HandleScope scope(isolate);
3894 Local<String> empty;
3895 global.Reset(isolate, empty);
3896 }
3897 CHECK(global.IsEmpty())do { if ((__builtin_expect(!!(!(global.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3897, "Check failed: %s.", "global.IsEmpty()"
); } } while (0)
;
3898 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global_handles
->global_handles_count()), (initial_handle_count - 1), "global_handles->global_handles_count()"
" " "==" " " "initial_handle_count - 1")) { V8_Fatal("../test/cctest/test-api.cc"
, 3898, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
3899}
3900
3901
3902template <class T>
3903static v8::Global<T> PassUnique(v8::Global<T> unique) {
3904 return unique.Pass();
3905}
3906
3907
3908template <class T>
3909static v8::Global<T> ReturnUnique(v8::Isolate* isolate,
3910 const v8::Persistent<T>& global) {
3911 v8::Global<String> unique(isolate, global);
3912 return unique.Pass();
3913}
3914
3915
3916THREADED_TEST(Global)static void TestGlobal(); RegisterThreadedTest register_Global
(TestGlobal, "Global"); static void TestGlobal(); CcTest register_test_Global
(TestGlobal, "../test/cctest/test-api.cc", "Global", __null, true
, true); static void TestGlobal()
{
3917 v8::Isolate* isolate = CcTest::isolate();
3918 v8::Persistent<String> global;
3919 {
3920 v8::HandleScope scope(isolate);
3921 global.Reset(isolate, v8_str("str"));
3922 }
3923 v8::internal::GlobalHandles* global_handles =
3924 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles();
3925 int initial_handle_count = global_handles->global_handles_count();
3926 {
3927 v8::Global<String> unique(isolate, global);
3928 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3928, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3929 // Test assignment via Pass
3930 {
3931 v8::Global<String> copy = unique.Pass();
3932 CHECK(unique.IsEmpty())do { if ((__builtin_expect(!!(!(unique.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3932, "Check failed: %s.", "unique.IsEmpty()"
); } } while (0)
;
3933 CHECK(copy == global)do { if ((__builtin_expect(!!(!(copy == global)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3933, "Check failed: %s.", "copy == global"
); } } while (0)
;
3934 CHECK_EQ(initial_handle_count + 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3935, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3935 global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3935, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3936 unique = copy.Pass();
3937 }
3938 // Test ctor via Pass
3939 {
3940 v8::Global<String> copy(unique.Pass());
3941 CHECK(unique.IsEmpty())do { if ((__builtin_expect(!!(!(unique.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3941, "Check failed: %s.", "unique.IsEmpty()"
); } } while (0)
;
3942 CHECK(copy == global)do { if ((__builtin_expect(!!(!(copy == global)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3942, "Check failed: %s.", "copy == global"
); } } while (0)
;
3943 CHECK_EQ(initial_handle_count + 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3944, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3944 global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3944, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3945 unique = copy.Pass();
3946 }
3947 // Test pass through function call
3948 {
3949 v8::Global<String> copy = PassUnique(unique.Pass());
3950 CHECK(unique.IsEmpty())do { if ((__builtin_expect(!!(!(unique.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3950, "Check failed: %s.", "unique.IsEmpty()"
); } } while (0)
;
3951 CHECK(copy == global)do { if ((__builtin_expect(!!(!(copy == global)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3951, "Check failed: %s.", "copy == global"
); } } while (0)
;
3952 CHECK_EQ(initial_handle_count + 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3953, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
3953 global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3953, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3954 unique = copy.Pass();
3955 }
3956 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3956, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3957 }
3958 // Test pass from function call
3959 {
3960 v8::Global<String> unique = ReturnUnique(isolate, global);
3961 CHECK(unique == global)do { if ((__builtin_expect(!!(!(unique == global)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3961, "Check failed: %s.", "unique == global"
); } } while (0)
;
3962 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3962, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3963 }
3964 CHECK_EQ(initial_handle_count, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
), (global_handles->global_handles_count()), "initial_handle_count"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 3964, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
3965 global.Reset();
3966}
3967
3968
3969namespace {
3970
3971class TwoPassCallbackData;
3972void FirstPassCallback(const v8::WeakCallbackInfo<TwoPassCallbackData>& data);
3973void SecondPassCallback(const v8::WeakCallbackInfo<TwoPassCallbackData>& data);
3974
3975
3976class TwoPassCallbackData {
3977 public:
3978 TwoPassCallbackData(v8::Isolate* isolate, int* instance_counter)
3979 : first_pass_called_(false),
3980 second_pass_called_(false),
3981 trigger_gc_(false),
3982 instance_counter_(instance_counter) {
3983 HandleScope scope(isolate);
3984 i::ScopedVector<char> buffer(40);
3985 i::SNPrintF(buffer, "%p", static_cast<void*>(this));
3986 auto string =
3987 v8::String::NewFromUtf8(isolate, buffer.start(),
3988 v8::NewStringType::kNormal).ToLocalChecked();
3989 cell_.Reset(isolate, string);
3990 (*instance_counter_)++;
3991 }
3992
3993 ~TwoPassCallbackData() {
3994 CHECK(first_pass_called_)do { if ((__builtin_expect(!!(!(first_pass_called_)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3994, "Check failed: %s.", "first_pass_called_"
); } } while (0)
;
3995 CHECK(second_pass_called_)do { if ((__builtin_expect(!!(!(second_pass_called_)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 3995, "Check failed: %s."
, "second_pass_called_"); } } while (0)
;
3996 CHECK(cell_.IsEmpty())do { if ((__builtin_expect(!!(!(cell_.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 3996, "Check failed: %s.", "cell_.IsEmpty()"
); } } while (0)
;
3997 (*instance_counter_)--;
3998 }
3999
4000 void FirstPass() {
4001 CHECK(!first_pass_called_)do { if ((__builtin_expect(!!(!(!first_pass_called_)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4001, "Check failed: %s."
, "!first_pass_called_"); } } while (0)
;
4002 CHECK(!second_pass_called_)do { if ((__builtin_expect(!!(!(!second_pass_called_)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4002, "Check failed: %s."
, "!second_pass_called_"); } } while (0)
;
4003 CHECK(!cell_.IsEmpty())do { if ((__builtin_expect(!!(!(!cell_.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4003, "Check failed: %s.", "!cell_.IsEmpty()"
); } } while (0)
;
4004 cell_.Reset();
4005 first_pass_called_ = true;
4006 }
4007
4008 void SecondPass() {
4009 CHECK(first_pass_called_)do { if ((__builtin_expect(!!(!(first_pass_called_)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4009, "Check failed: %s.", "first_pass_called_"
); } } while (0)
;
4010 CHECK(!second_pass_called_)do { if ((__builtin_expect(!!(!(!second_pass_called_)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4010, "Check failed: %s."
, "!second_pass_called_"); } } while (0)
;
4011 CHECK(cell_.IsEmpty())do { if ((__builtin_expect(!!(!(cell_.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4011, "Check failed: %s.", "cell_.IsEmpty()"
); } } while (0)
;
4012 second_pass_called_ = true;
4013 delete this;
4014 }
4015
4016 void SetWeak() {
4017 cell_.SetWeak(this, FirstPassCallback, v8::WeakCallbackType::kParameter);
4018 }
4019
4020 void MarkTriggerGc() { trigger_gc_ = true; }
4021 bool trigger_gc() { return trigger_gc_; }
4022
4023 int* instance_counter() { return instance_counter_; }
4024
4025 private:
4026 bool first_pass_called_;
4027 bool second_pass_called_;
4028 bool trigger_gc_;
4029 v8::Global<v8::String> cell_;
4030 int* instance_counter_;
4031};
4032
4033
4034void SecondPassCallback(const v8::WeakCallbackInfo<TwoPassCallbackData>& data) {
4035 ApiTestFuzzer::Fuzz();
4036 bool trigger_gc = data.GetParameter()->trigger_gc();
4037 int* instance_counter = data.GetParameter()->instance_counter();
4038 data.GetParameter()->SecondPass();
4039 if (!trigger_gc) return;
4040 auto data_2 = new TwoPassCallbackData(data.GetIsolate(), instance_counter);
4041 data_2->SetWeak();
4042 CcTest::heap()->CollectAllGarbage();
4043}
4044
4045
4046void FirstPassCallback(const v8::WeakCallbackInfo<TwoPassCallbackData>& data) {
4047 data.GetParameter()->FirstPass();
4048 data.SetSecondPassCallback(SecondPassCallback);
4049}
4050
4051} // namespace
4052
4053
4054TEST(TwoPassPhantomCallbacks)static void TestTwoPassPhantomCallbacks(); CcTest register_test_TwoPassPhantomCallbacks
(TestTwoPassPhantomCallbacks, "../test/cctest/test-api.cc", "TwoPassPhantomCallbacks"
, __null, true, true); static void TestTwoPassPhantomCallbacks
()
{
4055 auto isolate = CcTest::isolate();
4056 const size_t kLength = 20;
4057 int instance_counter = 0;
4058 for (size_t i = 0; i < kLength; ++i) {
4059 auto data = new TwoPassCallbackData(isolate, &instance_counter);
4060 data->SetWeak();
4061 }
4062 CHECK_EQ(static_cast<int>(kLength), instance_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int>(kLength)), (instance_counter), "static_cast<int>(kLength)"
" " "==" " " "instance_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 4062, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
4063 CcTest::heap()->CollectAllGarbage();
4064 EmptyMessageQueues(isolate);
4065 CHECK_EQ(0, instance_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (instance_counter
), "0" " " "==" " " "instance_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 4065, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
4066}
4067
4068
4069TEST(TwoPassPhantomCallbacksNestedGc)static void TestTwoPassPhantomCallbacksNestedGc(); CcTest register_test_TwoPassPhantomCallbacksNestedGc
(TestTwoPassPhantomCallbacksNestedGc, "../test/cctest/test-api.cc"
, "TwoPassPhantomCallbacksNestedGc", __null, true, true); static
void TestTwoPassPhantomCallbacksNestedGc()
{
4070 auto isolate = CcTest::isolate();
4071 const size_t kLength = 20;
4072 TwoPassCallbackData* array[kLength];
4073 int instance_counter = 0;
4074 for (size_t i = 0; i < kLength; ++i) {
4075 array[i] = new TwoPassCallbackData(isolate, &instance_counter);
4076 array[i]->SetWeak();
4077 }
4078 array[5]->MarkTriggerGc();
4079 array[10]->MarkTriggerGc();
4080 array[15]->MarkTriggerGc();
4081 CHECK_EQ(static_cast<int>(kLength), instance_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int>(kLength)), (instance_counter), "static_cast<int>(kLength)"
" " "==" " " "instance_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 4081, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
4082 CcTest::heap()->CollectAllGarbage();
4083 EmptyMessageQueues(isolate);
4084 CHECK_EQ(0, instance_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (instance_counter
), "0" " " "==" " " "instance_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 4084, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
4085}
4086
4087
4088namespace {
4089
4090void* IntKeyToVoidPointer(int key) { return reinterpret_cast<void*>(key << 1); }
4091
4092
4093Local<v8::Object> NewObjectForIntKey(
4094 v8::Isolate* isolate, const v8::Global<v8::ObjectTemplate>& templ,
4095 int key) {
4096 auto local = Local<v8::ObjectTemplate>::New(isolate, templ);
4097 auto obj = local->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
4098 obj->SetAlignedPointerInInternalField(0, IntKeyToVoidPointer(key));
4099 return obj;
4100}
4101
4102
4103template <typename K, typename V>
4104class PhantomStdMapTraits : public v8::StdMapTraits<K, V> {
4105 public:
4106 typedef typename v8::GlobalValueMap<K, V, PhantomStdMapTraits<K, V>> MapType;
4107 static const v8::PersistentContainerCallbackType kCallbackType =
4108 v8::kWeakWithInternalFields;
4109 struct WeakCallbackDataType {
4110 MapType* map;
4111 K key;
4112 };
4113 static WeakCallbackDataType* WeakCallbackParameter(MapType* map, const K& key,
4114 Local<V> value) {
4115 WeakCallbackDataType* data = new WeakCallbackDataType;
4116 data->map = map;
4117 data->key = key;
4118 return data;
4119 }
4120 static MapType* MapFromWeakCallbackInfo(
4121 const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {
4122 return data.GetParameter()->map;
4123 }
4124 static K KeyFromWeakCallbackInfo(
4125 const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {
4126 return data.GetParameter()->key;
4127 }
4128 static void DisposeCallbackData(WeakCallbackDataType* data) { delete data; }
4129 static void Dispose(v8::Isolate* isolate, v8::Global<V> value, K key) {
4130 CHECK_EQ(IntKeyToVoidPointer(key),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (IntKeyToVoidPointer
(key)), (v8::Object::GetAlignedPointerFromInternalField(value
, 0)), "IntKeyToVoidPointer(key)" " " "==" " " "v8::Object::GetAlignedPointerFromInternalField(value, 0)"
)) { V8_Fatal("../test/cctest/test-api.cc", 4131, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4131 v8::Object::GetAlignedPointerFromInternalField(value, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (IntKeyToVoidPointer
(key)), (v8::Object::GetAlignedPointerFromInternalField(value
, 0)), "IntKeyToVoidPointer(key)" " " "==" " " "v8::Object::GetAlignedPointerFromInternalField(value, 0)"
)) { V8_Fatal("../test/cctest/test-api.cc", 4131, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4132 }
4133 static void OnWeakCallback(
4134 const v8::WeakCallbackInfo<WeakCallbackDataType>&) {}
4135 static void DisposeWeak(
4136 const v8::WeakCallbackInfo<WeakCallbackDataType>& info) {
4137 K key = KeyFromWeakCallbackInfo(info);
4138 CHECK_EQ(IntKeyToVoidPointer(key), info.GetInternalField(0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (IntKeyToVoidPointer
(key)), (info.GetInternalField(0)), "IntKeyToVoidPointer(key)"
" " "==" " " "info.GetInternalField(0)")) { V8_Fatal("../test/cctest/test-api.cc"
, 4138, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
4139 DisposeCallbackData(info.GetParameter());
4140 }
4141};
4142
4143
4144template <typename Map>
4145void TestGlobalValueMap() {
4146 LocalContext env;
4147 v8::Isolate* isolate = env->GetIsolate();
4148 v8::Global<ObjectTemplate> templ;
4149 {
4150 HandleScope scope(isolate);
4151 auto t = ObjectTemplate::New(isolate);
4152 t->SetInternalFieldCount(1);
4153 templ.Reset(isolate, t);
4154 }
4155 Map map(isolate);
4156 v8::internal::GlobalHandles* global_handles =
4157 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles();
4158 int initial_handle_count = global_handles->global_handles_count();
4159 CHECK_EQ(0, static_cast<int>(map.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(map.Size())), "0" " " "==" " " "static_cast<int>(map.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4159, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4160 {
4161 HandleScope scope(isolate);
4162 Local<v8::Object> obj = map.Get(7);
4163 CHECK(obj.IsEmpty())do { if ((__builtin_expect(!!(!(obj.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4163, "Check failed: %s.", "obj.IsEmpty()"
); } } while (0)
;
4164 Local<v8::Object> expected = v8::Object::New(isolate);
4165 map.Set(7, expected);
4166 CHECK_EQ(1, static_cast<int>(map.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (static_cast
<int>(map.Size())), "1" " " "==" " " "static_cast<int>(map.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4166, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4167 obj = map.Get(7);
4168 CHECK(expected->Equals(env.local(), obj).FromJust())do { if ((__builtin_expect(!!(!(expected->Equals(env.local
(), obj).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4168, "Check failed: %s.", "expected->Equals(env.local(), obj).FromJust()"
); } } while (0)
;
4169 {
4170 typename Map::PersistentValueReference ref = map.GetReference(7);
4171 CHECK(expected->Equals(env.local(), ref.NewLocal(isolate)).FromJust())do { if ((__builtin_expect(!!(!(expected->Equals(env.local
(), ref.NewLocal(isolate)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4171, "Check failed: %s.", "expected->Equals(env.local(), ref.NewLocal(isolate)).FromJust()"
); } } while (0)
;
4172 }
4173 v8::Global<v8::Object> removed = map.Remove(7);
4174 CHECK_EQ(0, static_cast<int>(map.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(map.Size())), "0" " " "==" " " "static_cast<int>(map.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4174, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4175 CHECK(expected == removed)do { if ((__builtin_expect(!!(!(expected == removed)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4175, "Check failed: %s."
, "expected == removed"); } } while (0)
;
4176 removed = map.Remove(7);
4177 CHECK(removed.IsEmpty())do { if ((__builtin_expect(!!(!(removed.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4177, "Check failed: %s.", "removed.IsEmpty()"
); } } while (0)
;
4178 map.Set(8, expected);
4179 CHECK_EQ(1, static_cast<int>(map.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (static_cast
<int>(map.Size())), "1" " " "==" " " "static_cast<int>(map.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4179, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4180 map.Set(8, expected);
4181 CHECK_EQ(1, static_cast<int>(map.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (static_cast
<int>(map.Size())), "1" " " "==" " " "static_cast<int>(map.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4181, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4182 {
4183 typename Map::PersistentValueReference ref;
4184 Local<v8::Object> expected2 = NewObjectForIntKey(isolate, templ, 8);
4185 removed = map.Set(8, v8::Global<v8::Object>(isolate, expected2), &ref);
4186 CHECK_EQ(1, static_cast<int>(map.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (static_cast
<int>(map.Size())), "1" " " "==" " " "static_cast<int>(map.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4186, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4187 CHECK(expected == removed)do { if ((__builtin_expect(!!(!(expected == removed)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4187, "Check failed: %s."
, "expected == removed"); } } while (0)
;
4188 CHECK(expected2->Equals(env.local(), ref.NewLocal(isolate)).FromJust())do { if ((__builtin_expect(!!(!(expected2->Equals(env.local
(), ref.NewLocal(isolate)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4188, "Check failed: %s.", "expected2->Equals(env.local(), ref.NewLocal(isolate)).FromJust()"
); } } while (0)
;
4189 }
4190 }
4191 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
+ 1), (global_handles->global_handles_count()), "initial_handle_count + 1"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 4191, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4192 if (map.IsWeak()) {
4193 CcTest::i_isolate()->heap()->CollectAllGarbage(
4194 i::Heap::kAbortIncrementalMarkingMask);
4195 } else {
4196 map.Clear();
4197 }
4198 CHECK_EQ(0, static_cast<int>(map.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(map.Size())), "0" " " "==" " " "static_cast<int>(map.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4198, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4199 CHECK_EQ(initial_handle_count, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
), (global_handles->global_handles_count()), "initial_handle_count"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 4199, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4200 {
4201 HandleScope scope(isolate);
4202 Local<v8::Object> value = NewObjectForIntKey(isolate, templ, 9);
4203 map.Set(9, value);
4204 map.Clear();
4205 }
4206 CHECK_EQ(0, static_cast<int>(map.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(map.Size())), "0" " " "==" " " "static_cast<int>(map.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4206, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4207 CHECK_EQ(initial_handle_count, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handle_count
), (global_handles->global_handles_count()), "initial_handle_count"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 4207, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4208}
4209
4210} // namespace
4211
4212
4213TEST(GlobalValueMap)static void TestGlobalValueMap(); CcTest register_test_GlobalValueMap
(TestGlobalValueMap, "../test/cctest/test-api.cc", "GlobalValueMap"
, __null, true, true); static void TestGlobalValueMap()
{
4214 // Default case, w/o weak callbacks:
4215 TestGlobalValueMap<v8::StdGlobalValueMap<int, v8::Object>>();
4216
4217 // Custom traits with weak callbacks:
4218 typedef v8::GlobalValueMap<int, v8::Object,
4219 PhantomStdMapTraits<int, v8::Object>> WeakMap;
4220 TestGlobalValueMap<WeakMap>();
4221}
4222
4223
4224TEST(PersistentValueVector)static void TestPersistentValueVector(); CcTest register_test_PersistentValueVector
(TestPersistentValueVector, "../test/cctest/test-api.cc", "PersistentValueVector"
, __null, true, true); static void TestPersistentValueVector(
)
{
4225 LocalContext env;
4226 v8::Isolate* isolate = env->GetIsolate();
4227 v8::internal::GlobalHandles* global_handles =
4228 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles();
4229 int handle_count = global_handles->global_handles_count();
4230 HandleScope scope(isolate);
4231
4232 v8::PersistentValueVector<v8::Object> vector(isolate);
4233
4234 Local<v8::Object> obj1 = v8::Object::New(isolate);
4235 Local<v8::Object> obj2 = v8::Object::New(isolate);
4236 v8::Global<v8::Object> obj3(isolate, v8::Object::New(isolate));
4237
4238 CHECK(vector.IsEmpty())do { if ((__builtin_expect(!!(!(vector.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4238, "Check failed: %s.", "vector.IsEmpty()"
); } } while (0)
;
4239 CHECK_EQ(0, static_cast<int>(vector.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(vector.Size())), "0" " " "==" " " "static_cast<int>(vector.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4239, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4240
4241 vector.ReserveCapacity(3);
4242 CHECK(vector.IsEmpty())do { if ((__builtin_expect(!!(!(vector.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4242, "Check failed: %s.", "vector.IsEmpty()"
); } } while (0)
;
4243
4244 vector.Append(obj1);
4245 vector.Append(obj2);
4246 vector.Append(obj1);
4247 vector.Append(obj3.Pass());
4248 vector.Append(obj1);
4249
4250 CHECK(!vector.IsEmpty())do { if ((__builtin_expect(!!(!(!vector.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4250, "Check failed: %s.", "!vector.IsEmpty()"
); } } while (0)
;
4251 CHECK_EQ(5, static_cast<int>(vector.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (static_cast
<int>(vector.Size())), "5" " " "==" " " "static_cast<int>(vector.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4251, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4252 CHECK(obj3.IsEmpty())do { if ((__builtin_expect(!!(!(obj3.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4252, "Check failed: %s.", "obj3.IsEmpty()"
); } } while (0)
;
4253 CHECK(obj1->Equals(env.local(), vector.Get(0)).FromJust())do { if ((__builtin_expect(!!(!(obj1->Equals(env.local(), vector
.Get(0)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4253, "Check failed: %s.", "obj1->Equals(env.local(), vector.Get(0)).FromJust()"
); } } while (0)
;
4254 CHECK(obj1->Equals(env.local(), vector.Get(2)).FromJust())do { if ((__builtin_expect(!!(!(obj1->Equals(env.local(), vector
.Get(2)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4254, "Check failed: %s.", "obj1->Equals(env.local(), vector.Get(2)).FromJust()"
); } } while (0)
;
4255 CHECK(obj1->Equals(env.local(), vector.Get(4)).FromJust())do { if ((__builtin_expect(!!(!(obj1->Equals(env.local(), vector
.Get(4)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4255, "Check failed: %s.", "obj1->Equals(env.local(), vector.Get(4)).FromJust()"
); } } while (0)
;
4256 CHECK(obj2->Equals(env.local(), vector.Get(1)).FromJust())do { if ((__builtin_expect(!!(!(obj2->Equals(env.local(), vector
.Get(1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4256, "Check failed: %s.", "obj2->Equals(env.local(), vector.Get(1)).FromJust()"
); } } while (0)
;
4257
4258 CHECK_EQ(5 + handle_count, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5 + handle_count
), (global_handles->global_handles_count()), "5 + handle_count"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 4258, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4259
4260 vector.Clear();
4261 CHECK(vector.IsEmpty())do { if ((__builtin_expect(!!(!(vector.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4261, "Check failed: %s.", "vector.IsEmpty()"
); } } while (0)
;
4262 CHECK_EQ(0, static_cast<int>(vector.Size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(vector.Size())), "0" " " "==" " " "static_cast<int>(vector.Size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 4262, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4263 CHECK_EQ(handle_count, global_handles->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (handle_count
), (global_handles->global_handles_count()), "handle_count"
" " "==" " " "global_handles->global_handles_count()")) {
V8_Fatal("../test/cctest/test-api.cc", 4263, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4264}
4265
4266
4267THREADED_TEST(GlobalHandleUpcast)static void TestGlobalHandleUpcast(); RegisterThreadedTest register_GlobalHandleUpcast
(TestGlobalHandleUpcast, "GlobalHandleUpcast"); static void TestGlobalHandleUpcast
(); CcTest register_test_GlobalHandleUpcast(TestGlobalHandleUpcast
, "../test/cctest/test-api.cc", "GlobalHandleUpcast", __null,
true, true); static void TestGlobalHandleUpcast()
{
4268 v8::Isolate* isolate = CcTest::isolate();
4269 v8::HandleScope scope(isolate);
4270 v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str"));
4271 v8::Persistent<String> global_string(isolate, local);
4272 v8::Persistent<Value>& global_value =
4273 v8::Persistent<Value>::Cast(global_string);
4274 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString())do { if ((__builtin_expect(!!(!(v8::Local<v8::Value>::New
(isolate, global_value)->IsString())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4274, "Check failed: %s.", "v8::Local<v8::Value>::New(isolate, global_value)->IsString()"
); } } while (0)
;
4275 CHECK(global_string == v8::Persistent<String>::Cast(global_value))do { if ((__builtin_expect(!!(!(global_string == v8::Persistent
<String>::Cast(global_value))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4275, "Check failed: %s.", "global_string == v8::Persistent<String>::Cast(global_value)"
); } } while (0)
;
4276 global_string.Reset();
4277}
4278
4279
4280THREADED_TEST(HandleEquality)static void TestHandleEquality(); RegisterThreadedTest register_HandleEquality
(TestHandleEquality, "HandleEquality"); static void TestHandleEquality
(); CcTest register_test_HandleEquality(TestHandleEquality, "../test/cctest/test-api.cc"
, "HandleEquality", __null, true, true); static void TestHandleEquality
()
{
4281 v8::Isolate* isolate = CcTest::isolate();
4282 v8::Persistent<String> global1;
4283 v8::Persistent<String> global2;
4284 {
4285 v8::HandleScope scope(isolate);
4286 global1.Reset(isolate, v8_str("str"));
4287 global2.Reset(isolate, v8_str("str2"));
4288 }
4289 CHECK_EQ(global1 == global1, true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global1
== global1), (true), "global1 == global1" " " "==" " " "true"
)) { V8_Fatal("../test/cctest/test-api.cc", 4289, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4290 CHECK_EQ(global1 != global1, false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global1
!= global1), (false), "global1 != global1" " " "==" " " "false"
)) { V8_Fatal("../test/cctest/test-api.cc", 4290, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4291 {
4292 v8::HandleScope scope(isolate);
4293 Local<String> local1 = Local<String>::New(isolate, global1);
4294 Local<String> local2 = Local<String>::New(isolate, global2);
4295
4296 CHECK_EQ(global1 == local1, true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global1
== local1), (true), "global1 == local1" " " "==" " " "true")
) { V8_Fatal("../test/cctest/test-api.cc", 4296, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4297 CHECK_EQ(global1 != local1, false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global1
!= local1), (false), "global1 != local1" " " "==" " " "false"
)) { V8_Fatal("../test/cctest/test-api.cc", 4297, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4298 CHECK_EQ(local1 == global1, true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local1
== global1), (true), "local1 == global1" " " "==" " " "true"
)) { V8_Fatal("../test/cctest/test-api.cc", 4298, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4299 CHECK_EQ(local1 != global1, false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local1
!= global1), (false), "local1 != global1" " " "==" " " "false"
)) { V8_Fatal("../test/cctest/test-api.cc", 4299, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4300
4301 CHECK_EQ(global1 == local2, false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global1
== local2), (false), "global1 == local2" " " "==" " " "false"
)) { V8_Fatal("../test/cctest/test-api.cc", 4301, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4302 CHECK_EQ(global1 != local2, true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (global1
!= local2), (true), "global1 != local2" " " "==" " " "true")
) { V8_Fatal("../test/cctest/test-api.cc", 4302, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4303 CHECK_EQ(local2 == global1, false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local2
== global1), (false), "local2 == global1" " " "==" " " "false"
)) { V8_Fatal("../test/cctest/test-api.cc", 4303, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4304 CHECK_EQ(local2 != global1, true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local2
!= global1), (true), "local2 != global1" " " "==" " " "true"
)) { V8_Fatal("../test/cctest/test-api.cc", 4304, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4305
4306 CHECK_EQ(local1 == local2, false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local1
== local2), (false), "local1 == local2" " " "==" " " "false"
)) { V8_Fatal("../test/cctest/test-api.cc", 4306, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4307 CHECK_EQ(local1 != local2, true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local1
!= local2), (true), "local1 != local2" " " "==" " " "true"))
{ V8_Fatal("../test/cctest/test-api.cc", 4307, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4308
4309 Local<String> anotherLocal1 = Local<String>::New(isolate, global1);
4310 CHECK_EQ(local1 == anotherLocal1, true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local1
== anotherLocal1), (true), "local1 == anotherLocal1" " " "=="
" " "true")) { V8_Fatal("../test/cctest/test-api.cc", 4310, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4311 CHECK_EQ(local1 != anotherLocal1, false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local1
!= anotherLocal1), (false), "local1 != anotherLocal1" " " "=="
" " "false")) { V8_Fatal("../test/cctest/test-api.cc", 4311,
"Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
4312 }
4313 global1.Reset();
4314 global2.Reset();
4315}
4316
4317
4318THREADED_TEST(LocalHandle)static void TestLocalHandle(); RegisterThreadedTest register_LocalHandle
(TestLocalHandle, "LocalHandle"); static void TestLocalHandle
(); CcTest register_test_LocalHandle(TestLocalHandle, "../test/cctest/test-api.cc"
, "LocalHandle", __null, true, true); static void TestLocalHandle
()
{
4319 v8::HandleScope scope(CcTest::isolate());
4320 v8::Local<String> local =
4321 v8::Local<String>::New(CcTest::isolate(), v8_str("str"));
4322 CHECK_EQ(local->Length(), 3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (local->
Length()), (3), "local->Length()" " " "==" " " "3")) { V8_Fatal
("../test/cctest/test-api.cc", 4322, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
4323}
4324
4325
4326class WeakCallCounter {
4327 public:
4328 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) {}
4329 int id() { return id_; }
4330 void increment() { number_of_weak_calls_++; }
4331 int NumberOfWeakCalls() { return number_of_weak_calls_; }
4332
4333 private:
4334 int id_;
4335 int number_of_weak_calls_;
4336};
4337
4338
4339template <typename T>
4340struct WeakCallCounterAndPersistent {
4341 explicit WeakCallCounterAndPersistent(WeakCallCounter* counter)
4342 : counter(counter) {}
4343 WeakCallCounter* counter;
4344 v8::Persistent<T> handle;
4345};
4346
4347
4348template <typename T>
4349static void WeakPointerCallback(
4350 const v8::WeakCallbackInfo<WeakCallCounterAndPersistent<T>>& data) {
4351 CHECK_EQ(1234, data.GetParameter()->counter->id())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(data.GetParameter()->counter->id()), "1234" " " "==" " "
"data.GetParameter()->counter->id()")) { V8_Fatal("../test/cctest/test-api.cc"
, 4351, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
4352 data.GetParameter()->counter->increment();
4353 data.GetParameter()->handle.Reset();
4354}
4355
4356
4357template <typename T>
4358static UniqueId MakeUniqueId(const Persistent<T>& p) {
4359 return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p)));
4360}
4361
4362
4363THREADED_TEST(ApiObjectGroups)static void TestApiObjectGroups(); RegisterThreadedTest register_ApiObjectGroups
(TestApiObjectGroups, "ApiObjectGroups"); static void TestApiObjectGroups
(); CcTest register_test_ApiObjectGroups(TestApiObjectGroups,
"../test/cctest/test-api.cc", "ApiObjectGroups", __null, true
, true); static void TestApiObjectGroups()
{
4364 LocalContext env;
4365 v8::Isolate* iso = env->GetIsolate();
4366 HandleScope scope(iso);
4367
4368 WeakCallCounter counter(1234);
4369
4370 WeakCallCounterAndPersistent<Value> g1s1(&counter);
4371 WeakCallCounterAndPersistent<Value> g1s2(&counter);
4372 WeakCallCounterAndPersistent<Value> g1c1(&counter);
4373 WeakCallCounterAndPersistent<Value> g2s1(&counter);
4374 WeakCallCounterAndPersistent<Value> g2s2(&counter);
4375 WeakCallCounterAndPersistent<Value> g2c1(&counter);
4376
4377 {
4378 HandleScope scope(iso);
4379 g1s1.handle.Reset(iso, Object::New(iso));
4380 g1s2.handle.Reset(iso, Object::New(iso));
4381 g1c1.handle.Reset(iso, Object::New(iso));
4382 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback,
4383 v8::WeakCallbackType::kParameter);
4384 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback,
4385 v8::WeakCallbackType::kParameter);
4386 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback,
4387 v8::WeakCallbackType::kParameter);
4388
4389 g2s1.handle.Reset(iso, Object::New(iso));
4390 g2s2.handle.Reset(iso, Object::New(iso));
4391 g2c1.handle.Reset(iso, Object::New(iso));
4392 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback,
4393 v8::WeakCallbackType::kParameter);
4394 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback,
4395 v8::WeakCallbackType::kParameter);
4396 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback,
4397 v8::WeakCallbackType::kParameter);
4398 }
4399
4400 WeakCallCounterAndPersistent<Value> root(&counter);
4401 root.handle.Reset(iso, g1s1.handle); // make a root.
4402
4403 // Connect group 1 and 2, make a cycle.
4404 {
4405 HandleScope scope(iso);
4406 CHECK(Local<Object>::New(iso, g1s2.handle.As<Object>())do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g1s2.handle.As<Object>()) ->Set(env.local(), 0, Local
<Value>::New(iso, g2s2.handle)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4408, "Check failed: %s.", "Local<Object>::New(iso, g1s2.handle.As<Object>()) ->Set(env.local(), 0, Local<Value>::New(iso, g2s2.handle)) .FromJust()"
); } } while (0)
4407 ->Set(env.local(), 0, Local<Value>::New(iso, g2s2.handle))do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g1s2.handle.As<Object>()) ->Set(env.local(), 0, Local
<Value>::New(iso, g2s2.handle)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4408, "Check failed: %s.", "Local<Object>::New(iso, g1s2.handle.As<Object>()) ->Set(env.local(), 0, Local<Value>::New(iso, g2s2.handle)) .FromJust()"
); } } while (0)
4408 .FromJust())do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g1s2.handle.As<Object>()) ->Set(env.local(), 0, Local
<Value>::New(iso, g2s2.handle)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4408, "Check failed: %s.", "Local<Object>::New(iso, g1s2.handle.As<Object>()) ->Set(env.local(), 0, Local<Value>::New(iso, g2s2.handle)) .FromJust()"
); } } while (0)
;
4409 CHECK(Local<Object>::New(iso, g2s1.handle.As<Object>())do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g2s1.handle.As<Object>()) ->Set(env.local(), 0, Local
<Value>::New(iso, g1s1.handle)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4411, "Check failed: %s.", "Local<Object>::New(iso, g2s1.handle.As<Object>()) ->Set(env.local(), 0, Local<Value>::New(iso, g1s1.handle)) .FromJust()"
); } } while (0)
4410 ->Set(env.local(), 0, Local<Value>::New(iso, g1s1.handle))do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g2s1.handle.As<Object>()) ->Set(env.local(), 0, Local
<Value>::New(iso, g1s1.handle)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4411, "Check failed: %s.", "Local<Object>::New(iso, g2s1.handle.As<Object>()) ->Set(env.local(), 0, Local<Value>::New(iso, g1s1.handle)) .FromJust()"
); } } while (0)
4411 .FromJust())do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g2s1.handle.As<Object>()) ->Set(env.local(), 0, Local
<Value>::New(iso, g1s1.handle)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4411, "Check failed: %s.", "Local<Object>::New(iso, g2s1.handle.As<Object>()) ->Set(env.local(), 0, Local<Value>::New(iso, g1s1.handle)) .FromJust()"
); } } while (0)
;
4412 }
4413
4414 {
4415 UniqueId id1 = MakeUniqueId(g1s1.handle);
4416 UniqueId id2 = MakeUniqueId(g2s2.handle);
4417 iso->SetObjectGroupId(g1s1.handle, id1);
4418 iso->SetObjectGroupId(g1s2.handle, id1);
4419 iso->SetReferenceFromGroup(id1, g1c1.handle);
4420 iso->SetObjectGroupId(g2s1.handle, id2);
4421 iso->SetObjectGroupId(g2s2.handle, id2);
4422 iso->SetReferenceFromGroup(id2, g2c1.handle);
4423 }
4424 // Do a single full GC, ensure incremental marking is stopped.
4425 v8::internal::Heap* heap =
4426 reinterpret_cast<v8::internal::Isolate*>(iso)->heap();
4427 heap->CollectAllGarbage();
4428
4429 // All object should be alive.
4430 CHECK_EQ(0, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (counter
.NumberOfWeakCalls()), "0" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4430, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4431
4432 // Weaken the root.
4433 root.handle.SetWeak(&root, &WeakPointerCallback,
4434 v8::WeakCallbackType::kParameter);
4435 // But make children strong roots---all the objects (except for children)
4436 // should be collectable now.
4437 g1c1.handle.ClearWeak();
4438 g2c1.handle.ClearWeak();
4439
4440 // Groups are deleted, rebuild groups.
4441 {
4442 UniqueId id1 = MakeUniqueId(g1s1.handle);
4443 UniqueId id2 = MakeUniqueId(g2s2.handle);
4444 iso->SetObjectGroupId(g1s1.handle, id1);
4445 iso->SetObjectGroupId(g1s2.handle, id1);
4446 iso->SetReferenceFromGroup(id1, g1c1.handle);
4447 iso->SetObjectGroupId(g2s1.handle, id2);
4448 iso->SetObjectGroupId(g2s2.handle, id2);
4449 iso->SetReferenceFromGroup(id2, g2c1.handle);
4450 }
4451
4452 heap->CollectAllGarbage();
4453
4454 // All objects should be gone. 5 global handles in total.
4455 CHECK_EQ(5, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (counter
.NumberOfWeakCalls()), "5" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4455, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4456
4457 // And now make children weak again and collect them.
4458 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback,
4459 v8::WeakCallbackType::kParameter);
4460 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback,
4461 v8::WeakCallbackType::kParameter);
4462
4463 heap->CollectAllGarbage();
4464 CHECK_EQ(7, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (counter
.NumberOfWeakCalls()), "7" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4464, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4465}
4466
4467
4468THREADED_TEST(ApiObjectGroupsForSubtypes)static void TestApiObjectGroupsForSubtypes(); RegisterThreadedTest
register_ApiObjectGroupsForSubtypes(TestApiObjectGroupsForSubtypes
, "ApiObjectGroupsForSubtypes"); static void TestApiObjectGroupsForSubtypes
(); CcTest register_test_ApiObjectGroupsForSubtypes(TestApiObjectGroupsForSubtypes
, "../test/cctest/test-api.cc", "ApiObjectGroupsForSubtypes",
__null, true, true); static void TestApiObjectGroupsForSubtypes
()
{
4469 LocalContext env;
4470 v8::Isolate* iso = env->GetIsolate();
4471 HandleScope scope(iso);
4472
4473 WeakCallCounter counter(1234);
4474
4475 WeakCallCounterAndPersistent<Object> g1s1(&counter);
4476 WeakCallCounterAndPersistent<String> g1s2(&counter);
4477 WeakCallCounterAndPersistent<String> g1c1(&counter);
4478 WeakCallCounterAndPersistent<Object> g2s1(&counter);
4479 WeakCallCounterAndPersistent<String> g2s2(&counter);
4480 WeakCallCounterAndPersistent<String> g2c1(&counter);
4481
4482 {
4483 HandleScope scope(iso);
4484 g1s1.handle.Reset(iso, Object::New(iso));
4485 g1s2.handle.Reset(iso, v8_str("foo1"));
4486 g1c1.handle.Reset(iso, v8_str("foo2"));
4487 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback,
4488 v8::WeakCallbackType::kParameter);
4489 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback,
4490 v8::WeakCallbackType::kParameter);
4491 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback,
4492 v8::WeakCallbackType::kParameter);
4493
4494 g2s1.handle.Reset(iso, Object::New(iso));
4495 g2s2.handle.Reset(iso, v8_str("foo3"));
4496 g2c1.handle.Reset(iso, v8_str("foo4"));
4497 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback,
4498 v8::WeakCallbackType::kParameter);
4499 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback,
4500 v8::WeakCallbackType::kParameter);
4501 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback,
4502 v8::WeakCallbackType::kParameter);
4503 }
4504
4505 WeakCallCounterAndPersistent<Value> root(&counter);
4506 root.handle.Reset(iso, g1s1.handle); // make a root.
4507
4508 // Connect group 1 and 2, make a cycle.
4509 {
4510 HandleScope scope(iso);
4511 CHECK(Local<Object>::New(iso, g1s1.handle)do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g1s1.handle) ->Set(env.local(), 0, Local<Object>::New
(iso, g2s1.handle)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4513, "Check failed: %s.", "Local<Object>::New(iso, g1s1.handle) ->Set(env.local(), 0, Local<Object>::New(iso, g2s1.handle)) .FromJust()"
); } } while (0)
4512 ->Set(env.local(), 0, Local<Object>::New(iso, g2s1.handle))do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g1s1.handle) ->Set(env.local(), 0, Local<Object>::New
(iso, g2s1.handle)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4513, "Check failed: %s.", "Local<Object>::New(iso, g1s1.handle) ->Set(env.local(), 0, Local<Object>::New(iso, g2s1.handle)) .FromJust()"
); } } while (0)
4513 .FromJust())do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g1s1.handle) ->Set(env.local(), 0, Local<Object>::New
(iso, g2s1.handle)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4513, "Check failed: %s.", "Local<Object>::New(iso, g1s1.handle) ->Set(env.local(), 0, Local<Object>::New(iso, g2s1.handle)) .FromJust()"
); } } while (0)
;
4514 CHECK(Local<Object>::New(iso, g2s1.handle)do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g2s1.handle) ->Set(env.local(), 0, Local<Object>::New
(iso, g1s1.handle)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4516, "Check failed: %s.", "Local<Object>::New(iso, g2s1.handle) ->Set(env.local(), 0, Local<Object>::New(iso, g1s1.handle)) .FromJust()"
); } } while (0)
4515 ->Set(env.local(), 0, Local<Object>::New(iso, g1s1.handle))do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g2s1.handle) ->Set(env.local(), 0, Local<Object>::New
(iso, g1s1.handle)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4516, "Check failed: %s.", "Local<Object>::New(iso, g2s1.handle) ->Set(env.local(), 0, Local<Object>::New(iso, g1s1.handle)) .FromJust()"
); } } while (0)
4516 .FromJust())do { if ((__builtin_expect(!!(!(Local<Object>::New(iso,
g2s1.handle) ->Set(env.local(), 0, Local<Object>::New
(iso, g1s1.handle)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4516, "Check failed: %s.", "Local<Object>::New(iso, g2s1.handle) ->Set(env.local(), 0, Local<Object>::New(iso, g1s1.handle)) .FromJust()"
); } } while (0)
;
4517 }
4518
4519 {
4520 UniqueId id1 = MakeUniqueId(g1s1.handle);
4521 UniqueId id2 = MakeUniqueId(g2s2.handle);
4522 iso->SetObjectGroupId(g1s1.handle, id1);
4523 iso->SetObjectGroupId(g1s2.handle, id1);
4524 iso->SetReference(g1s1.handle, g1c1.handle);
4525 iso->SetObjectGroupId(g2s1.handle, id2);
4526 iso->SetObjectGroupId(g2s2.handle, id2);
4527 iso->SetReferenceFromGroup(id2, g2c1.handle);
4528 }
4529 // Do a single full GC, ensure incremental marking is stopped.
4530 v8::internal::Heap* heap =
4531 reinterpret_cast<v8::internal::Isolate*>(iso)->heap();
4532 heap->CollectAllGarbage();
4533
4534 // All object should be alive.
4535 CHECK_EQ(0, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (counter
.NumberOfWeakCalls()), "0" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4535, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4536
4537 // Weaken the root.
4538 root.handle.SetWeak(&root, &WeakPointerCallback,
4539 v8::WeakCallbackType::kParameter);
4540 // But make children strong roots---all the objects (except for children)
4541 // should be collectable now.
4542 g1c1.handle.ClearWeak();
4543 g2c1.handle.ClearWeak();
4544
4545 // Groups are deleted, rebuild groups.
4546 {
4547 UniqueId id1 = MakeUniqueId(g1s1.handle);
4548 UniqueId id2 = MakeUniqueId(g2s2.handle);
4549 iso->SetObjectGroupId(g1s1.handle, id1);
4550 iso->SetObjectGroupId(g1s2.handle, id1);
4551 iso->SetReference(g1s1.handle, g1c1.handle);
4552 iso->SetObjectGroupId(g2s1.handle, id2);
4553 iso->SetObjectGroupId(g2s2.handle, id2);
4554 iso->SetReferenceFromGroup(id2, g2c1.handle);
4555 }
4556
4557 heap->CollectAllGarbage();
4558
4559 // All objects should be gone. 5 global handles in total.
4560 CHECK_EQ(5, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (counter
.NumberOfWeakCalls()), "5" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4560, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4561
4562 // And now make children weak again and collect them.
4563 g1c1.handle.SetWeak(&g1c1, &WeakPointerCallback,
4564 v8::WeakCallbackType::kParameter);
4565 g2c1.handle.SetWeak(&g2c1, &WeakPointerCallback,
4566 v8::WeakCallbackType::kParameter);
4567
4568 heap->CollectAllGarbage();
4569 CHECK_EQ(7, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (counter
.NumberOfWeakCalls()), "7" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4569, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4570}
4571
4572
4573THREADED_TEST(ApiObjectGroupsCycle)static void TestApiObjectGroupsCycle(); RegisterThreadedTest register_ApiObjectGroupsCycle
(TestApiObjectGroupsCycle, "ApiObjectGroupsCycle"); static void
TestApiObjectGroupsCycle(); CcTest register_test_ApiObjectGroupsCycle
(TestApiObjectGroupsCycle, "../test/cctest/test-api.cc", "ApiObjectGroupsCycle"
, __null, true, true); static void TestApiObjectGroupsCycle()
{
4574 LocalContext env;
4575 v8::Isolate* iso = env->GetIsolate();
4576 HandleScope scope(iso);
4577
4578 WeakCallCounter counter(1234);
4579
4580 WeakCallCounterAndPersistent<Value> g1s1(&counter);
4581 WeakCallCounterAndPersistent<Value> g1s2(&counter);
4582 WeakCallCounterAndPersistent<Value> g2s1(&counter);
4583 WeakCallCounterAndPersistent<Value> g2s2(&counter);
4584 WeakCallCounterAndPersistent<Value> g3s1(&counter);
4585 WeakCallCounterAndPersistent<Value> g3s2(&counter);
4586 WeakCallCounterAndPersistent<Value> g4s1(&counter);
4587 WeakCallCounterAndPersistent<Value> g4s2(&counter);
4588
4589 {
4590 HandleScope scope(iso);
4591 g1s1.handle.Reset(iso, Object::New(iso));
4592 g1s2.handle.Reset(iso, Object::New(iso));
4593 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback,
4594 v8::WeakCallbackType::kParameter);
4595 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback,
4596 v8::WeakCallbackType::kParameter);
4597 CHECK(g1s1.handle.IsWeak())do { if ((__builtin_expect(!!(!(g1s1.handle.IsWeak())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4597, "Check failed: %s."
, "g1s1.handle.IsWeak()"); } } while (0)
;
4598 CHECK(g1s2.handle.IsWeak())do { if ((__builtin_expect(!!(!(g1s2.handle.IsWeak())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4598, "Check failed: %s."
, "g1s2.handle.IsWeak()"); } } while (0)
;
4599
4600 g2s1.handle.Reset(iso, Object::New(iso));
4601 g2s2.handle.Reset(iso, Object::New(iso));
4602 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback,
4603 v8::WeakCallbackType::kParameter);
4604 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback,
4605 v8::WeakCallbackType::kParameter);
4606 CHECK(g2s1.handle.IsWeak())do { if ((__builtin_expect(!!(!(g2s1.handle.IsWeak())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4606, "Check failed: %s."
, "g2s1.handle.IsWeak()"); } } while (0)
;
4607 CHECK(g2s2.handle.IsWeak())do { if ((__builtin_expect(!!(!(g2s2.handle.IsWeak())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4607, "Check failed: %s."
, "g2s2.handle.IsWeak()"); } } while (0)
;
4608
4609 g3s1.handle.Reset(iso, Object::New(iso));
4610 g3s2.handle.Reset(iso, Object::New(iso));
4611 g3s1.handle.SetWeak(&g3s1, &WeakPointerCallback,
4612 v8::WeakCallbackType::kParameter);
4613 g3s2.handle.SetWeak(&g3s2, &WeakPointerCallback,
4614 v8::WeakCallbackType::kParameter);
4615 CHECK(g3s1.handle.IsWeak())do { if ((__builtin_expect(!!(!(g3s1.handle.IsWeak())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4615, "Check failed: %s."
, "g3s1.handle.IsWeak()"); } } while (0)
;
4616 CHECK(g3s2.handle.IsWeak())do { if ((__builtin_expect(!!(!(g3s2.handle.IsWeak())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4616, "Check failed: %s."
, "g3s2.handle.IsWeak()"); } } while (0)
;
4617
4618 g4s1.handle.Reset(iso, Object::New(iso));
4619 g4s2.handle.Reset(iso, Object::New(iso));
4620 g4s1.handle.SetWeak(&g4s1, &WeakPointerCallback,
4621 v8::WeakCallbackType::kParameter);
4622 g4s2.handle.SetWeak(&g4s2, &WeakPointerCallback,
4623 v8::WeakCallbackType::kParameter);
4624 CHECK(g4s1.handle.IsWeak())do { if ((__builtin_expect(!!(!(g4s1.handle.IsWeak())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4624, "Check failed: %s."
, "g4s1.handle.IsWeak()"); } } while (0)
;
4625 CHECK(g4s2.handle.IsWeak())do { if ((__builtin_expect(!!(!(g4s2.handle.IsWeak())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4625, "Check failed: %s."
, "g4s2.handle.IsWeak()"); } } while (0)
;
4626 }
4627
4628 WeakCallCounterAndPersistent<Value> root(&counter);
4629 root.handle.Reset(iso, g1s1.handle); // make a root.
4630
4631 // Connect groups. We're building the following cycle:
4632 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
4633 // groups.
4634 {
4635 UniqueId id1 = MakeUniqueId(g1s1.handle);
4636 UniqueId id2 = MakeUniqueId(g2s1.handle);
4637 UniqueId id3 = MakeUniqueId(g3s1.handle);
4638 UniqueId id4 = MakeUniqueId(g4s1.handle);
4639 iso->SetObjectGroupId(g1s1.handle, id1);
4640 iso->SetObjectGroupId(g1s2.handle, id1);
4641 iso->SetReferenceFromGroup(id1, g2s1.handle);
4642 iso->SetObjectGroupId(g2s1.handle, id2);
4643 iso->SetObjectGroupId(g2s2.handle, id2);
4644 iso->SetReferenceFromGroup(id2, g3s1.handle);
4645 iso->SetObjectGroupId(g3s1.handle, id3);
4646 iso->SetObjectGroupId(g3s2.handle, id3);
4647 iso->SetReferenceFromGroup(id3, g4s1.handle);
4648 iso->SetObjectGroupId(g4s1.handle, id4);
4649 iso->SetObjectGroupId(g4s2.handle, id4);
4650 iso->SetReferenceFromGroup(id4, g1s1.handle);
4651 }
4652 // Do a single full GC
4653 v8::internal::Heap* heap =
4654 reinterpret_cast<v8::internal::Isolate*>(iso)->heap();
4655 heap->CollectAllGarbage();
4656
4657 // All object should be alive.
4658 CHECK_EQ(0, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (counter
.NumberOfWeakCalls()), "0" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4658, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4659
4660 // Weaken the root.
4661 root.handle.SetWeak(&root, &WeakPointerCallback,
4662 v8::WeakCallbackType::kParameter);
4663
4664 // Groups are deleted, rebuild groups.
4665 {
4666 UniqueId id1 = MakeUniqueId(g1s1.handle);
4667 UniqueId id2 = MakeUniqueId(g2s1.handle);
4668 UniqueId id3 = MakeUniqueId(g3s1.handle);
4669 UniqueId id4 = MakeUniqueId(g4s1.handle);
4670 iso->SetObjectGroupId(g1s1.handle, id1);
4671 iso->SetObjectGroupId(g1s2.handle, id1);
4672 iso->SetReferenceFromGroup(id1, g2s1.handle);
4673 iso->SetObjectGroupId(g2s1.handle, id2);
4674 iso->SetObjectGroupId(g2s2.handle, id2);
4675 iso->SetReferenceFromGroup(id2, g3s1.handle);
4676 iso->SetObjectGroupId(g3s1.handle, id3);
4677 iso->SetObjectGroupId(g3s2.handle, id3);
4678 iso->SetReferenceFromGroup(id3, g4s1.handle);
4679 iso->SetObjectGroupId(g4s1.handle, id4);
4680 iso->SetObjectGroupId(g4s2.handle, id4);
4681 iso->SetReferenceFromGroup(id4, g1s1.handle);
4682 }
4683
4684 heap->CollectAllGarbage();
4685
4686 // All objects should be gone. 9 global handles in total.
4687 CHECK_EQ(9, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9), (counter
.NumberOfWeakCalls()), "9" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4687, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4688}
4689
4690
4691// TODO(mstarzinger): This should be a THREADED_TEST but causes failures
4692// on the buildbots, so was made non-threaded for the time being.
4693TEST(ApiObjectGroupsCycleForScavenger)static void TestApiObjectGroupsCycleForScavenger(); CcTest register_test_ApiObjectGroupsCycleForScavenger
(TestApiObjectGroupsCycleForScavenger, "../test/cctest/test-api.cc"
, "ApiObjectGroupsCycleForScavenger", __null, true, true); static
void TestApiObjectGroupsCycleForScavenger()
{
4694 i::FLAG_stress_compaction = false;
4695 i::FLAG_gc_global = false;
4696 LocalContext env;
4697 v8::Isolate* iso = env->GetIsolate();
4698 HandleScope scope(iso);
4699
4700 WeakCallCounter counter(1234);
4701
4702 WeakCallCounterAndPersistent<Value> g1s1(&counter);
4703 WeakCallCounterAndPersistent<Value> g1s2(&counter);
4704 WeakCallCounterAndPersistent<Value> g2s1(&counter);
4705 WeakCallCounterAndPersistent<Value> g2s2(&counter);
4706 WeakCallCounterAndPersistent<Value> g3s1(&counter);
4707 WeakCallCounterAndPersistent<Value> g3s2(&counter);
4708
4709 {
4710 HandleScope scope(iso);
4711 g1s1.handle.Reset(iso, Object::New(iso));
4712 g1s2.handle.Reset(iso, Object::New(iso));
4713 g1s1.handle.SetWeak(&g1s1, &WeakPointerCallback,
4714 v8::WeakCallbackType::kParameter);
4715 g1s2.handle.SetWeak(&g1s2, &WeakPointerCallback,
4716 v8::WeakCallbackType::kParameter);
4717
4718 g2s1.handle.Reset(iso, Object::New(iso));
4719 g2s2.handle.Reset(iso, Object::New(iso));
4720 g2s1.handle.SetWeak(&g2s1, &WeakPointerCallback,
4721 v8::WeakCallbackType::kParameter);
4722 g2s2.handle.SetWeak(&g2s2, &WeakPointerCallback,
4723 v8::WeakCallbackType::kParameter);
4724
4725 g3s1.handle.Reset(iso, Object::New(iso));
4726 g3s2.handle.Reset(iso, Object::New(iso));
4727 g3s1.handle.SetWeak(&g3s1, &WeakPointerCallback,
4728 v8::WeakCallbackType::kParameter);
4729 g3s2.handle.SetWeak(&g3s2, &WeakPointerCallback,
4730 v8::WeakCallbackType::kParameter);
4731 }
4732
4733 // Make a root.
4734 WeakCallCounterAndPersistent<Value> root(&counter);
4735 root.handle.Reset(iso, g1s1.handle);
4736 root.handle.MarkPartiallyDependent();
4737
4738 // Connect groups. We're building the following cycle:
4739 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
4740 // groups.
4741 {
4742 HandleScope handle_scope(iso);
4743 g1s1.handle.MarkPartiallyDependent();
4744 g1s2.handle.MarkPartiallyDependent();
4745 g2s1.handle.MarkPartiallyDependent();
4746 g2s2.handle.MarkPartiallyDependent();
4747 g3s1.handle.MarkPartiallyDependent();
4748 g3s2.handle.MarkPartiallyDependent();
4749 iso->SetObjectGroupId(g1s1.handle, UniqueId(1));
4750 iso->SetObjectGroupId(g1s2.handle, UniqueId(1));
4751 Local<Object>::New(iso, g1s1.handle.As<Object>())
4752 ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g2s1.handle))
4753 .FromJust();
4754 iso->SetObjectGroupId(g2s1.handle, UniqueId(2));
4755 iso->SetObjectGroupId(g2s2.handle, UniqueId(2));
4756 Local<Object>::New(iso, g2s1.handle.As<Object>())
4757 ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g3s1.handle))
4758 .FromJust();
4759 iso->SetObjectGroupId(g3s1.handle, UniqueId(3));
4760 iso->SetObjectGroupId(g3s2.handle, UniqueId(3));
4761 Local<Object>::New(iso, g3s1.handle.As<Object>())
4762 ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g1s1.handle))
4763 .FromJust();
4764 }
4765
4766 v8::internal::Heap* heap =
4767 reinterpret_cast<v8::internal::Isolate*>(iso)->heap();
4768 heap->CollectAllGarbage();
4769
4770 // All objects should be alive.
4771 CHECK_EQ(0, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (counter
.NumberOfWeakCalls()), "0" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4771, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4772
4773 // Weaken the root.
4774 root.handle.SetWeak(&root, &WeakPointerCallback,
4775 v8::WeakCallbackType::kParameter);
4776 root.handle.MarkPartiallyDependent();
4777
4778 // Groups are deleted, rebuild groups.
4779 {
4780 HandleScope handle_scope(iso);
4781 g1s1.handle.MarkPartiallyDependent();
4782 g1s2.handle.MarkPartiallyDependent();
4783 g2s1.handle.MarkPartiallyDependent();
4784 g2s2.handle.MarkPartiallyDependent();
4785 g3s1.handle.MarkPartiallyDependent();
4786 g3s2.handle.MarkPartiallyDependent();
4787 iso->SetObjectGroupId(g1s1.handle, UniqueId(1));
4788 iso->SetObjectGroupId(g1s2.handle, UniqueId(1));
4789 Local<Object>::New(iso, g1s1.handle.As<Object>())
4790 ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g2s1.handle))
4791 .FromJust();
4792 iso->SetObjectGroupId(g2s1.handle, UniqueId(2));
4793 iso->SetObjectGroupId(g2s2.handle, UniqueId(2));
4794 Local<Object>::New(iso, g2s1.handle.As<Object>())
4795 ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g3s1.handle))
4796 .FromJust();
4797 iso->SetObjectGroupId(g3s1.handle, UniqueId(3));
4798 iso->SetObjectGroupId(g3s2.handle, UniqueId(3));
4799 Local<Object>::New(iso, g3s1.handle.As<Object>())
4800 ->Set(env.local(), v8_str("x"), Local<Value>::New(iso, g1s1.handle))
4801 .FromJust();
4802 }
4803
4804 heap->CollectAllGarbage();
4805
4806 // All objects should be gone. 7 global handles in total.
4807 CHECK_EQ(7, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (counter
.NumberOfWeakCalls()), "7" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4807, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4808}
4809
4810
4811THREADED_TEST(ScriptException)static void TestScriptException(); RegisterThreadedTest register_ScriptException
(TestScriptException, "ScriptException"); static void TestScriptException
(); CcTest register_test_ScriptException(TestScriptException,
"../test/cctest/test-api.cc", "ScriptException", __null, true
, true); static void TestScriptException()
{
4812 LocalContext env;
4813 v8::HandleScope scope(env->GetIsolate());
4814 Local<Script> script = v8_compile("throw 'panama!';");
4815 v8::TryCatch try_catch(env->GetIsolate());
4816 v8::MaybeLocal<Value> result = script->Run(env.local());
4817 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4817, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
4818 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 4818, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
4819 String::Utf8Value exception_value(try_catch.Exception());
4820 CHECK_EQ(0, strcmp(*exception_value, "panama!"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "panama!")), "0" " " "==" " " "strcmp(*exception_value, \"panama!\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 4820, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4821}
4822
4823
4824TEST(TryCatchCustomException)static void TestTryCatchCustomException(); CcTest register_test_TryCatchCustomException
(TestTryCatchCustomException, "../test/cctest/test-api.cc", "TryCatchCustomException"
, __null, true, true); static void TestTryCatchCustomException
()
{
4825 LocalContext env;
4826 v8::Isolate* isolate = env->GetIsolate();
4827 v8::HandleScope scope(isolate);
4828 v8::TryCatch try_catch(isolate);
4829 CompileRun(
4830 "function CustomError() { this.a = 'b'; }"
4831 "(function f() { throw new CustomError(); })();");
4832 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 4832, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
4833 CHECK(try_catch.Exception()do { if ((__builtin_expect(!!(!(try_catch.Exception() ->ToObject
(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(
"a")) .ToLocalChecked() ->Equals(env.local(), v8_str("b"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4839, "Check failed: %s.", "try_catch.Exception() ->ToObject(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(\"a\")) .ToLocalChecked() ->Equals(env.local(), v8_str(\"b\")) .FromJust()"
); } } while (0)
4834 ->ToObject(env.local())do { if ((__builtin_expect(!!(!(try_catch.Exception() ->ToObject
(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(
"a")) .ToLocalChecked() ->Equals(env.local(), v8_str("b"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4839, "Check failed: %s.", "try_catch.Exception() ->ToObject(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(\"a\")) .ToLocalChecked() ->Equals(env.local(), v8_str(\"b\")) .FromJust()"
); } } while (0)
4835 .ToLocalChecked()do { if ((__builtin_expect(!!(!(try_catch.Exception() ->ToObject
(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(
"a")) .ToLocalChecked() ->Equals(env.local(), v8_str("b"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4839, "Check failed: %s.", "try_catch.Exception() ->ToObject(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(\"a\")) .ToLocalChecked() ->Equals(env.local(), v8_str(\"b\")) .FromJust()"
); } } while (0)
4836 ->Get(env.local(), v8_str("a"))do { if ((__builtin_expect(!!(!(try_catch.Exception() ->ToObject
(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(
"a")) .ToLocalChecked() ->Equals(env.local(), v8_str("b"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4839, "Check failed: %s.", "try_catch.Exception() ->ToObject(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(\"a\")) .ToLocalChecked() ->Equals(env.local(), v8_str(\"b\")) .FromJust()"
); } } while (0)
4837 .ToLocalChecked()do { if ((__builtin_expect(!!(!(try_catch.Exception() ->ToObject
(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(
"a")) .ToLocalChecked() ->Equals(env.local(), v8_str("b"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4839, "Check failed: %s.", "try_catch.Exception() ->ToObject(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(\"a\")) .ToLocalChecked() ->Equals(env.local(), v8_str(\"b\")) .FromJust()"
); } } while (0)
4838 ->Equals(env.local(), v8_str("b"))do { if ((__builtin_expect(!!(!(try_catch.Exception() ->ToObject
(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(
"a")) .ToLocalChecked() ->Equals(env.local(), v8_str("b"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4839, "Check failed: %s.", "try_catch.Exception() ->ToObject(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(\"a\")) .ToLocalChecked() ->Equals(env.local(), v8_str(\"b\")) .FromJust()"
); } } while (0)
4839 .FromJust())do { if ((__builtin_expect(!!(!(try_catch.Exception() ->ToObject
(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(
"a")) .ToLocalChecked() ->Equals(env.local(), v8_str("b"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4839, "Check failed: %s.", "try_catch.Exception() ->ToObject(env.local()) .ToLocalChecked() ->Get(env.local(), v8_str(\"a\")) .ToLocalChecked() ->Equals(env.local(), v8_str(\"b\")) .FromJust()"
); } } while (0)
;
4840}
4841
4842
4843bool message_received;
4844
4845
4846static void check_message_0(v8::Local<v8::Message> message,
4847 v8::Local<Value> data) {
4848 CHECK_EQ(5.76, data->NumberValue(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.76),
(data->NumberValue(CcTest::isolate()->GetCurrentContext
()) .FromJust()), "5.76" " " "==" " " "data->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4849, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4849 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.76),
(data->NumberValue(CcTest::isolate()->GetCurrentContext
()) .FromJust()), "5.76" " " "==" " " "data->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4849, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4850 CHECK_EQ(6.75, message->GetScriptOrigin()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4853, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4851 .ResourceName()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4853, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4852 ->NumberValue(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4853, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4853 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4853, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4854 CHECK(!message->IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(!message->IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 4854, "Check failed: %s."
, "!message->IsSharedCrossOrigin()"); } } while (0)
;
4855 message_received = true;
4856}
4857
4858
4859THREADED_TEST(MessageHandler0)static void TestMessageHandler0(); RegisterThreadedTest register_MessageHandler0
(TestMessageHandler0, "MessageHandler0"); static void TestMessageHandler0
(); CcTest register_test_MessageHandler0(TestMessageHandler0,
"../test/cctest/test-api.cc", "MessageHandler0", __null, true
, true); static void TestMessageHandler0()
{
4860 message_received = false;
4861 v8::HandleScope scope(CcTest::isolate());
4862 CHECK(!message_received)do { if ((__builtin_expect(!!(!(!message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4862, "Check failed: %s.", "!message_received"
); } } while (0)
;
4863 LocalContext context;
4864 CcTest::isolate()->AddMessageListener(check_message_0, v8_num(5.76));
4865 v8::Local<v8::Script> script = CompileWithOrigin("throw 'error'", "6.75");
4866 CHECK(script->Run(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(context.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4866, "Check failed: %s.", "script->Run(context.local()).IsEmpty()"
); } } while (0)
;
4867 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4867, "Check failed: %s.", "message_received"
); } } while (0)
;
4868 // clear out the message listener
4869 CcTest::isolate()->RemoveMessageListeners(check_message_0);
4870}
4871
4872
4873static void check_message_1(v8::Local<v8::Message> message,
4874 v8::Local<Value> data) {
4875 CHECK(data->IsNumber())do { if ((__builtin_expect(!!(!(data->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4875, "Check failed: %s."
, "data->IsNumber()"); } } while (0)
;
4876 CHECK_EQ(1337,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1337),
(data->Int32Value(CcTest::isolate()->GetCurrentContext
()).FromJust()), "1337" " " "==" " " "data->Int32Value(CcTest::isolate()->GetCurrentContext()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4877, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4877 data->Int32Value(CcTest::isolate()->GetCurrentContext()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1337),
(data->Int32Value(CcTest::isolate()->GetCurrentContext
()).FromJust()), "1337" " " "==" " " "data->Int32Value(CcTest::isolate()->GetCurrentContext()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4877, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4878 CHECK(!message->IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(!message->IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 4878, "Check failed: %s."
, "!message->IsSharedCrossOrigin()"); } } while (0)
;
4879 message_received = true;
4880}
4881
4882
4883TEST(MessageHandler1)static void TestMessageHandler1(); CcTest register_test_MessageHandler1
(TestMessageHandler1, "../test/cctest/test-api.cc", "MessageHandler1"
, __null, true, true); static void TestMessageHandler1()
{
4884 message_received = false;
4885 v8::HandleScope scope(CcTest::isolate());
4886 CHECK(!message_received)do { if ((__builtin_expect(!!(!(!message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4886, "Check failed: %s.", "!message_received"
); } } while (0)
;
4887 CcTest::isolate()->AddMessageListener(check_message_1);
4888 LocalContext context;
4889 CompileRun("throw 1337;");
4890 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4890, "Check failed: %s.", "message_received"
); } } while (0)
;
4891 // clear out the message listener
4892 CcTest::isolate()->RemoveMessageListeners(check_message_1);
4893}
4894
4895
4896static void check_message_2(v8::Local<v8::Message> message,
4897 v8::Local<Value> data) {
4898 LocalContext context;
4899 CHECK(data->IsObject())do { if ((__builtin_expect(!!(!(data->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 4899, "Check failed: %s."
, "data->IsObject()"); } } while (0)
;
4900 v8::Local<v8::Value> hidden_property =
4901 v8::Object::Cast(*data)
4902 ->GetPrivate(
4903 context.local(),
4904 v8::Private::ForApi(CcTest::isolate(), v8_str("hidden key")))
4905 .ToLocalChecked();
4906 CHECK(v8_str("hidden value")do { if ((__builtin_expect(!!(!(v8_str("hidden value") ->Equals
(context.local(), hidden_property) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4908, "Check failed: %s.", "v8_str(\"hidden value\") ->Equals(context.local(), hidden_property) .FromJust()"
); } } while (0)
4907 ->Equals(context.local(), hidden_property)do { if ((__builtin_expect(!!(!(v8_str("hidden value") ->Equals
(context.local(), hidden_property) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4908, "Check failed: %s.", "v8_str(\"hidden value\") ->Equals(context.local(), hidden_property) .FromJust()"
); } } while (0)
4908 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("hidden value") ->Equals
(context.local(), hidden_property) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4908, "Check failed: %s.", "v8_str(\"hidden value\") ->Equals(context.local(), hidden_property) .FromJust()"
); } } while (0)
;
4909 CHECK(!message->IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(!message->IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 4909, "Check failed: %s."
, "!message->IsSharedCrossOrigin()"); } } while (0)
;
4910 message_received = true;
4911}
4912
4913
4914TEST(MessageHandler2)static void TestMessageHandler2(); CcTest register_test_MessageHandler2
(TestMessageHandler2, "../test/cctest/test-api.cc", "MessageHandler2"
, __null, true, true); static void TestMessageHandler2()
{
4915 message_received = false;
4916 v8::HandleScope scope(CcTest::isolate());
4917 CHECK(!message_received)do { if ((__builtin_expect(!!(!(!message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4917, "Check failed: %s.", "!message_received"
); } } while (0)
;
4918 CcTest::isolate()->AddMessageListener(check_message_2);
4919 LocalContext context;
4920 v8::Local<v8::Value> error = v8::Exception::Error(v8_str("custom error"));
4921 v8::Object::Cast(*error)
4922 ->SetPrivate(context.local(),
4923 v8::Private::ForApi(CcTest::isolate(), v8_str("hidden key")),
4924 v8_str("hidden value"))
4925 .FromJust();
4926 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("error"), error) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 4928, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"error\"), error) .FromJust()"
); } } while (0)
4927 ->Set(context.local(), v8_str("error"), error)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("error"), error) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 4928, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"error\"), error) .FromJust()"
); } } while (0)
4928 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("error"), error) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 4928, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"error\"), error) .FromJust()"
); } } while (0)
;
4929 CompileRun("throw error;");
4930 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4930, "Check failed: %s.", "message_received"
); } } while (0)
;
4931 // clear out the message listener
4932 CcTest::isolate()->RemoveMessageListeners(check_message_2);
4933}
4934
4935
4936static void check_message_3(v8::Local<v8::Message> message,
4937 v8::Local<Value> data) {
4938 CHECK(message->IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(message->IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 4938, "Check failed: %s."
, "message->IsSharedCrossOrigin()"); } } while (0)
;
4939 CHECK(message->GetScriptOrigin().Options().IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(message->GetScriptOrigin()
.Options().IsSharedCrossOrigin())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4939, "Check failed: %s.", "message->GetScriptOrigin().Options().IsSharedCrossOrigin()"
); } } while (0)
;
4940 CHECK(message->GetScriptOrigin().Options().IsEmbedderDebugScript())do { if ((__builtin_expect(!!(!(message->GetScriptOrigin()
.Options().IsEmbedderDebugScript())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4940, "Check failed: %s.", "message->GetScriptOrigin().Options().IsEmbedderDebugScript()"
); } } while (0)
;
4941 CHECK(message->GetScriptOrigin().Options().IsOpaque())do { if ((__builtin_expect(!!(!(message->GetScriptOrigin()
.Options().IsOpaque())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 4941, "Check failed: %s.", "message->GetScriptOrigin().Options().IsOpaque()"
); } } while (0)
;
4942 CHECK_EQ(6.75, message->GetScriptOrigin()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4945, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4943 .ResourceName()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4945, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4944 ->NumberValue(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4945, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4945 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4945, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4946 CHECK_EQ(7.40, message->GetScriptOrigin()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.40),
(message->GetScriptOrigin() .SourceMapUrl() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "7.40"
" " "==" " " "message->GetScriptOrigin() .SourceMapUrl() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4949, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4947 .SourceMapUrl()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.40),
(message->GetScriptOrigin() .SourceMapUrl() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "7.40"
" " "==" " " "message->GetScriptOrigin() .SourceMapUrl() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4949, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4948 ->NumberValue(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.40),
(message->GetScriptOrigin() .SourceMapUrl() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "7.40"
" " "==" " " "message->GetScriptOrigin() .SourceMapUrl() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4949, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4949 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.40),
(message->GetScriptOrigin() .SourceMapUrl() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "7.40"
" " "==" " " "message->GetScriptOrigin() .SourceMapUrl() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4949, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4950 message_received = true;
4951}
4952
4953
4954TEST(MessageHandler3)static void TestMessageHandler3(); CcTest register_test_MessageHandler3
(TestMessageHandler3, "../test/cctest/test-api.cc", "MessageHandler3"
, __null, true, true); static void TestMessageHandler3()
{
4955 message_received = false;
4956 v8::Isolate* isolate = CcTest::isolate();
4957 v8::HandleScope scope(isolate);
4958 CHECK(!message_received)do { if ((__builtin_expect(!!(!(!message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4958, "Check failed: %s.", "!message_received"
); } } while (0)
;
4959 isolate->AddMessageListener(check_message_3);
4960 LocalContext context;
4961 v8::ScriptOrigin origin = v8::ScriptOrigin(
4962 v8_str("6.75"), v8::Integer::New(isolate, 1),
4963 v8::Integer::New(isolate, 2), v8::True(isolate), Local<v8::Integer>(),
4964 v8::True(isolate), v8_str("7.40"), v8::True(isolate));
4965 v8::Local<v8::Script> script =
4966 Script::Compile(context.local(), v8_str("throw 'error'"), &origin)
4967 .ToLocalChecked();
4968 CHECK(script->Run(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(context.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4968, "Check failed: %s.", "script->Run(context.local()).IsEmpty()"
); } } while (0)
;
4969 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4969, "Check failed: %s.", "message_received"
); } } while (0)
;
4970 // clear out the message listener
4971 isolate->RemoveMessageListeners(check_message_3);
4972}
4973
4974
4975static void check_message_4(v8::Local<v8::Message> message,
4976 v8::Local<Value> data) {
4977 CHECK(!message->IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(!message->IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 4977, "Check failed: %s."
, "!message->IsSharedCrossOrigin()"); } } while (0)
;
4978 CHECK_EQ(6.75, message->GetScriptOrigin()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4981, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4979 .ResourceName()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4981, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4980 ->NumberValue(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4981, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
4981 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 4981, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
4982 message_received = true;
4983}
4984
4985
4986TEST(MessageHandler4)static void TestMessageHandler4(); CcTest register_test_MessageHandler4
(TestMessageHandler4, "../test/cctest/test-api.cc", "MessageHandler4"
, __null, true, true); static void TestMessageHandler4()
{
4987 message_received = false;
4988 v8::Isolate* isolate = CcTest::isolate();
4989 v8::HandleScope scope(isolate);
4990 CHECK(!message_received)do { if ((__builtin_expect(!!(!(!message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 4990, "Check failed: %s.", "!message_received"
); } } while (0)
;
4991 isolate->AddMessageListener(check_message_4);
4992 LocalContext context;
4993 v8::ScriptOrigin origin =
4994 v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
4995 v8::Integer::New(isolate, 2), v8::False(isolate));
4996 v8::Local<v8::Script> script =
4997 Script::Compile(context.local(), v8_str("throw 'error'"), &origin)
4998 .ToLocalChecked();
4999 CHECK(script->Run(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(context.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
4999, "Check failed: %s.", "script->Run(context.local()).IsEmpty()"
); } } while (0)
;
5000 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5000, "Check failed: %s.", "message_received"
); } } while (0)
;
5001 // clear out the message listener
5002 isolate->RemoveMessageListeners(check_message_4);
5003}
5004
5005
5006static void check_message_5a(v8::Local<v8::Message> message,
5007 v8::Local<Value> data) {
5008 CHECK(message->IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(message->IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5008, "Check failed: %s."
, "message->IsSharedCrossOrigin()"); } } while (0)
;
5009 CHECK_EQ(6.75, message->GetScriptOrigin()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5012, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5010 .ResourceName()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5012, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5011 ->NumberValue(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5012, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5012 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5012, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5013 message_received = true;
5014}
5015
5016
5017static void check_message_5b(v8::Local<v8::Message> message,
5018 v8::Local<Value> data) {
5019 CHECK(!message->IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(!message->IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5019, "Check failed: %s."
, "!message->IsSharedCrossOrigin()"); } } while (0)
;
5020 CHECK_EQ(6.75, message->GetScriptOrigin()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5023, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5021 .ResourceName()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5023, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5022 ->NumberValue(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5023, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5023 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.75),
(message->GetScriptOrigin() .ResourceName() ->NumberValue
(CcTest::isolate()->GetCurrentContext()) .FromJust()), "6.75"
" " "==" " " "message->GetScriptOrigin() .ResourceName() ->NumberValue(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5023, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5024 message_received = true;
5025}
5026
5027
5028TEST(MessageHandler5)static void TestMessageHandler5(); CcTest register_test_MessageHandler5
(TestMessageHandler5, "../test/cctest/test-api.cc", "MessageHandler5"
, __null, true, true); static void TestMessageHandler5()
{
5029 message_received = false;
5030 v8::Isolate* isolate = CcTest::isolate();
5031 v8::HandleScope scope(isolate);
5032 CHECK(!message_received)do { if ((__builtin_expect(!!(!(!message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5032, "Check failed: %s.", "!message_received"
); } } while (0)
;
5033 isolate->AddMessageListener(check_message_5a);
5034 LocalContext context;
5035 v8::ScriptOrigin origin1 =
5036 v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
5037 v8::Integer::New(isolate, 2), v8::True(isolate));
5038 v8::Local<v8::Script> script =
5039 Script::Compile(context.local(), v8_str("throw 'error'"), &origin1)
5040 .ToLocalChecked();
5041 CHECK(script->Run(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(context.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
5041, "Check failed: %s.", "script->Run(context.local()).IsEmpty()"
); } } while (0)
;
5042 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5042, "Check failed: %s.", "message_received"
); } } while (0)
;
5043 // clear out the message listener
5044 isolate->RemoveMessageListeners(check_message_5a);
5045
5046 message_received = false;
5047 isolate->AddMessageListener(check_message_5b);
5048 v8::ScriptOrigin origin2 =
5049 v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
5050 v8::Integer::New(isolate, 2), v8::False(isolate));
5051 script = Script::Compile(context.local(), v8_str("throw 'error'"), &origin2)
5052 .ToLocalChecked();
5053 CHECK(script->Run(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(context.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
5053, "Check failed: %s.", "script->Run(context.local()).IsEmpty()"
); } } while (0)
;
5054 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5054, "Check failed: %s.", "message_received"
); } } while (0)
;
5055 // clear out the message listener
5056 isolate->RemoveMessageListeners(check_message_5b);
5057}
5058
5059
5060TEST(NativeWeakMap)static void TestNativeWeakMap(); CcTest register_test_NativeWeakMap
(TestNativeWeakMap, "../test/cctest/test-api.cc", "NativeWeakMap"
, __null, true, true); static void TestNativeWeakMap()
{
5061 v8::Isolate* isolate = CcTest::isolate();
5062 HandleScope scope(isolate);
5063 Local<v8::NativeWeakMap> weak_map(v8::NativeWeakMap::New(isolate));
5064 CHECK(!weak_map.IsEmpty())do { if ((__builtin_expect(!!(!(!weak_map.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5064, "Check failed: %s."
, "!weak_map.IsEmpty()"); } } while (0)
;
5065
5066 LocalContext env;
5067 Local<Object> value = v8::Object::New(isolate);
5068
5069 Local<Object> local1 = v8::Object::New(isolate);
5070 CHECK(!weak_map->Has(local1))do { if ((__builtin_expect(!!(!(!weak_map->Has(local1))), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5070, "Check failed: %s."
, "!weak_map->Has(local1)"); } } while (0)
;
5071 CHECK(weak_map->Get(local1)->IsUndefined())do { if ((__builtin_expect(!!(!(weak_map->Get(local1)->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5071, "Check failed: %s.", "weak_map->Get(local1)->IsUndefined()"
); } } while (0)
;
5072 weak_map->Set(local1, value);
5073 CHECK(weak_map->Has(local1))do { if ((__builtin_expect(!!(!(weak_map->Has(local1))), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5073, "Check failed: %s."
, "weak_map->Has(local1)"); } } while (0)
;
5074 CHECK(value->Equals(env.local(), weak_map->Get(local1)).FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(local1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5074, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(local1)).FromJust()"
); } } while (0)
;
5075
5076 WeakCallCounter counter(1234);
5077 WeakCallCounterAndPersistent<Value> o1(&counter);
5078 WeakCallCounterAndPersistent<Value> o2(&counter);
5079 WeakCallCounterAndPersistent<Value> s1(&counter);
5080 {
5081 HandleScope scope(isolate);
5082 Local<v8::Object> obj1 = v8::Object::New(isolate);
5083 Local<v8::Object> obj2 = v8::Object::New(isolate);
5084 Local<v8::Symbol> sym1 = v8::Symbol::New(isolate);
5085
5086 weak_map->Set(obj1, value);
5087 weak_map->Set(obj2, value);
5088 weak_map->Set(sym1, value);
5089
5090 o1.handle.Reset(isolate, obj1);
5091 o2.handle.Reset(isolate, obj2);
5092 s1.handle.Reset(isolate, sym1);
5093
5094 CHECK(weak_map->Has(local1))do { if ((__builtin_expect(!!(!(weak_map->Has(local1))), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5094, "Check failed: %s."
, "weak_map->Has(local1)"); } } while (0)
;
5095 CHECK(weak_map->Has(obj1))do { if ((__builtin_expect(!!(!(weak_map->Has(obj1))), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 5095, "Check failed: %s."
, "weak_map->Has(obj1)"); } } while (0)
;
5096 CHECK(weak_map->Has(obj2))do { if ((__builtin_expect(!!(!(weak_map->Has(obj2))), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 5096, "Check failed: %s."
, "weak_map->Has(obj2)"); } } while (0)
;
5097 CHECK(weak_map->Has(sym1))do { if ((__builtin_expect(!!(!(weak_map->Has(sym1))), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 5097, "Check failed: %s."
, "weak_map->Has(sym1)"); } } while (0)
;
5098
5099 CHECK(value->Equals(env.local(), weak_map->Get(local1)).FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(local1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5099, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(local1)).FromJust()"
); } } while (0)
;
5100 CHECK(value->Equals(env.local(), weak_map->Get(obj1)).FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(obj1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5100, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(obj1)).FromJust()"
); } } while (0)
;
5101 CHECK(value->Equals(env.local(), weak_map->Get(obj2)).FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(obj2)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5101, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(obj2)).FromJust()"
); } } while (0)
;
5102 CHECK(value->Equals(env.local(), weak_map->Get(sym1)).FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(sym1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5102, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(sym1)).FromJust()"
); } } while (0)
;
5103 }
5104 CcTest::heap()->CollectAllGarbage();
5105 {
5106 HandleScope scope(isolate);
5107 CHECK(value->Equals(env.local(), weak_map->Get(local1)).FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(local1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5107, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(local1)).FromJust()"
); } } while (0)
;
5108 CHECK(value->Equals(env.local(),do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, o1.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5110, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, o1.handle))) .FromJust()"
); } } while (0)
5109 weak_map->Get(Local<Value>::New(isolate, o1.handle)))do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, o1.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5110, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, o1.handle))) .FromJust()"
); } } while (0)
5110 .FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, o1.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5110, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, o1.handle))) .FromJust()"
); } } while (0)
;
5111 CHECK(value->Equals(env.local(),do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, o2.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5113, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, o2.handle))) .FromJust()"
); } } while (0)
5112 weak_map->Get(Local<Value>::New(isolate, o2.handle)))do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, o2.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5113, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, o2.handle))) .FromJust()"
); } } while (0)
5113 .FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, o2.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5113, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, o2.handle))) .FromJust()"
); } } while (0)
;
5114 CHECK(value->Equals(env.local(),do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, s1.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5116, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, s1.handle))) .FromJust()"
); } } while (0)
5115 weak_map->Get(Local<Value>::New(isolate, s1.handle)))do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, s1.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5116, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, s1.handle))) .FromJust()"
); } } while (0)
5116 .FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(Local<Value>::New(isolate, s1.handle)
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5116, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(Local<Value>::New(isolate, s1.handle))) .FromJust()"
); } } while (0)
;
5117 }
5118
5119 o1.handle.SetWeak(&o1, &WeakPointerCallback,
5120 v8::WeakCallbackType::kParameter);
5121 o2.handle.SetWeak(&o2, &WeakPointerCallback,
5122 v8::WeakCallbackType::kParameter);
5123 s1.handle.SetWeak(&s1, &WeakPointerCallback,
5124 v8::WeakCallbackType::kParameter);
5125
5126 CcTest::heap()->CollectAllGarbage();
5127 CHECK_EQ(3, counter.NumberOfWeakCalls())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (counter
.NumberOfWeakCalls()), "3" " " "==" " " "counter.NumberOfWeakCalls()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5127, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5128
5129 CHECK(o1.handle.IsEmpty())do { if ((__builtin_expect(!!(!(o1.handle.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5129, "Check failed: %s."
, "o1.handle.IsEmpty()"); } } while (0)
;
5130 CHECK(o2.handle.IsEmpty())do { if ((__builtin_expect(!!(!(o2.handle.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5130, "Check failed: %s."
, "o2.handle.IsEmpty()"); } } while (0)
;
5131 CHECK(s1.handle.IsEmpty())do { if ((__builtin_expect(!!(!(s1.handle.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5131, "Check failed: %s."
, "s1.handle.IsEmpty()"); } } while (0)
;
5132
5133 CHECK(value->Equals(env.local(), weak_map->Get(local1)).FromJust())do { if ((__builtin_expect(!!(!(value->Equals(env.local(),
weak_map->Get(local1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5133, "Check failed: %s.", "value->Equals(env.local(), weak_map->Get(local1)).FromJust()"
); } } while (0)
;
5134 CHECK(weak_map->Delete(local1))do { if ((__builtin_expect(!!(!(weak_map->Delete(local1)))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 5134, "Check failed: %s."
, "weak_map->Delete(local1)"); } } while (0)
;
5135 CHECK(!weak_map->Has(local1))do { if ((__builtin_expect(!!(!(!weak_map->Has(local1))), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5135, "Check failed: %s."
, "!weak_map->Has(local1)"); } } while (0)
;
5136 CHECK(weak_map->Get(local1)->IsUndefined())do { if ((__builtin_expect(!!(!(weak_map->Get(local1)->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5136, "Check failed: %s.", "weak_map->Get(local1)->IsUndefined()"
); } } while (0)
;
5137}
5138
5139
5140THREADED_TEST(GetSetProperty)static void TestGetSetProperty(); RegisterThreadedTest register_GetSetProperty
(TestGetSetProperty, "GetSetProperty"); static void TestGetSetProperty
(); CcTest register_test_GetSetProperty(TestGetSetProperty, "../test/cctest/test-api.cc"
, "GetSetProperty", __null, true, true); static void TestGetSetProperty
()
{
5141 LocalContext context;
5142 v8::Isolate* isolate = context->GetIsolate();
5143 v8::HandleScope scope(isolate);
5144 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("foo"), v8_num(14)) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5146, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"foo\"), v8_num(14)) .FromJust()"
); } } while (0)
5145 ->Set(context.local(), v8_str("foo"), v8_num(14))do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("foo"), v8_num(14)) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5146, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"foo\"), v8_num(14)) .FromJust()"
); } } while (0)
5146 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("foo"), v8_num(14)) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5146, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"foo\"), v8_num(14)) .FromJust()"
); } } while (0)
;
5147 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("12"), v8_num(92)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 5149, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"12\"), v8_num(92)) .FromJust()"
); } } while (0)
5148 ->Set(context.local(), v8_str("12"), v8_num(92))do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("12"), v8_num(92)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 5149, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"12\"), v8_num(92)) .FromJust()"
); } } while (0)
5149 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("12"), v8_num(92)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 5149, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"12\"), v8_num(92)) .FromJust()"
); } } while (0)
;
5150 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8::Integer::New(isolate, 16), v8_num(32)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5152
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8::Integer::New(isolate, 16), v8_num(32)) .FromJust()"
); } } while (0)
5151 ->Set(context.local(), v8::Integer::New(isolate, 16), v8_num(32))do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8::Integer::New(isolate, 16), v8_num(32)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5152
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8::Integer::New(isolate, 16), v8_num(32)) .FromJust()"
); } } while (0)
5152 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8::Integer::New(isolate, 16), v8_num(32)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5152
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8::Integer::New(isolate, 16), v8_num(32)) .FromJust()"
); } } while (0)
;
5153 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_num(13), v8_num(56)) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 5155, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_num(13), v8_num(56)) .FromJust()"
); } } while (0)
5154 ->Set(context.local(), v8_num(13), v8_num(56))do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_num(13), v8_num(56)) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 5155, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_num(13), v8_num(56)) .FromJust()"
); } } while (0)
5155 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_num(13), v8_num(56)) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 5155, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_num(13), v8_num(56)) .FromJust()"
); } } while (0)
;
5156 Local<Value> foo = CompileRun("this.foo");
5157 CHECK_EQ(14, foo->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (14), (
foo->Int32Value(context.local()).FromJust()), "14" " " "=="
" " "foo->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 5157, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5158 Local<Value> twelve = CompileRun("this[12]");
5159 CHECK_EQ(92, twelve->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
twelve->Int32Value(context.local()).FromJust()), "92" " " "=="
" " "twelve->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 5159, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5160 Local<Value> sixteen = CompileRun("this[16]");
5161 CHECK_EQ(32, sixteen->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
sixteen->Int32Value(context.local()).FromJust()), "32" " "
"==" " " "sixteen->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5161, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5162 Local<Value> thirteen = CompileRun("this[13]");
5163 CHECK_EQ(56, thirteen->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
thirteen->Int32Value(context.local()).FromJust()), "56" " "
"==" " " "thirteen->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5163, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5164 CHECK_EQ(92, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "92" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5168, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5165 ->Get(context.local(), v8::Integer::New(isolate, 12))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "92" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5168, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5166 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "92" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5168, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5167 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "92" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5168, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5168 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "92" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5168, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5169 CHECK_EQ(92, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_str("12")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "92" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"12\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5173, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5170 ->Get(context.local(), v8_str("12"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_str("12")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "92" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"12\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5173, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5171 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_str("12")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "92" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"12\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5173, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5172 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_str("12")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "92" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"12\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5173, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5173 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_str("12")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "92" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"12\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5173, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5174 CHECK_EQ(92, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "92" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5178, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5175 ->Get(context.local(), v8_num(12))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "92" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5178, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5176 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "92" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5178, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5177 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "92" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5178, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5178 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "92" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(12)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5178, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5179 CHECK_EQ(32, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "32" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5183, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5180 ->Get(context.local(), v8::Integer::New(isolate, 16))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "32" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5183, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5181 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "32" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5183, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5182 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "32" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5183, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5183 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "32" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5183, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5184 CHECK_EQ(32, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_str("16")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "32" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"16\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5188, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5185 ->Get(context.local(), v8_str("16"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_str("16")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "32" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"16\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5188, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5186 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_str("16")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "32" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"16\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5188, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5187 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_str("16")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "32" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"16\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5188, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5188 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_str("16")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "32" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"16\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5188, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5189 CHECK_EQ(32, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "32" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5193, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5190 ->Get(context.local(), v8_num(16))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "32" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5193, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5191 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "32" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5193, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5192 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "32" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5193, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5193 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "32" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(16)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5193, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5194 CHECK_EQ(56, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "56" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5198, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5195 ->Get(context.local(), v8::Integer::New(isolate, 13))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "56" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5198, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5196 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "56" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5198, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5197 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "56" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5198, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5198 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8::Integer::New
(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local
()) .FromJust()), "56" " " "==" " " "context->Global() ->Get(context.local(), v8::Integer::New(isolate, 13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5198, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5199 CHECK_EQ(56, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_str("13")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "56" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"13\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5203, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5200 ->Get(context.local(), v8_str("13"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_str("13")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "56" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"13\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5203, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5201 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_str("13")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "56" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"13\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5203, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5202 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_str("13")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "56" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"13\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5203, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5203 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_str("13")) .
ToLocalChecked() ->Int32Value(context.local()) .FromJust()
), "56" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"13\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5203, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5204 CHECK_EQ(56, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "56" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5208, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5205 ->Get(context.local(), v8_num(13))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "56" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5208, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5206 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "56" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5208, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5207 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "56" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5208, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5208 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (56), (
context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "56" " " "=="
" " "context->Global() ->Get(context.local(), v8_num(13)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5208, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5209}
5210
5211
5212THREADED_TEST(PropertyAttributes)static void TestPropertyAttributes(); RegisterThreadedTest register_PropertyAttributes
(TestPropertyAttributes, "PropertyAttributes"); static void TestPropertyAttributes
(); CcTest register_test_PropertyAttributes(TestPropertyAttributes
, "../test/cctest/test-api.cc", "PropertyAttributes", __null,
true, true); static void TestPropertyAttributes()
{
5213 LocalContext context;
5214 v8::HandleScope scope(context->GetIsolate());
5215 // none
5216 Local<String> prop = v8_str("none");
5217 CHECK(context->Global()->Set(context.local(), prop, v8_num(7)).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), prop, v8_num(7)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5217, "Check failed: %s.", "context->Global()->Set(context.local(), prop, v8_num(7)).FromJust()"
); } } while (0)
;
5218 CHECK_EQ(v8::None, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5220, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5219 ->GetPropertyAttributes(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5220, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5220 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5220, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5221 // read-only
5222 prop = v8_str("read_only");
5223 context->Global()
5224 ->DefineOwnProperty(context.local(), prop, v8_num(7), v8::ReadOnly)
5225 .FromJust();
5226 CHECK_EQ(7, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5230, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5227 ->Get(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5230, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5228 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5230, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5229 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5230, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5230 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5230, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5231 CHECK_EQ(v8::ReadOnly, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::ReadOnly
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::ReadOnly" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5233, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5232 ->GetPropertyAttributes(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::ReadOnly
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::ReadOnly" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5233, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5233 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::ReadOnly
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::ReadOnly" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5233, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5234 CompileRun("read_only = 9");
5235 CHECK_EQ(7, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5239, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5236 ->Get(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5239, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5237 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5239, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5238 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5239, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5239 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5239, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5240 CHECK(context->Global()->Set(context.local(), prop, v8_num(10)).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), prop, v8_num(10)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5240, "Check failed: %s.", "context->Global()->Set(context.local(), prop, v8_num(10)).FromJust()"
); } } while (0)
;
5241 CHECK_EQ(7, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5245, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5242 ->Get(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5245, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5243 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5245, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5244 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5245, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5245 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (context
->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "7" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5245, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5246 // dont-delete
5247 prop = v8_str("dont_delete");
5248 context->Global()
5249 ->DefineOwnProperty(context.local(), prop, v8_num(13), v8::DontDelete)
5250 .FromJust();
5251 CHECK_EQ(13, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5255, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5252 ->Get(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5255, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5253 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5255, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5254 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5255, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5255 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5255, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5256 CompileRun("delete dont_delete");
5257 CHECK_EQ(13, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5261, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5258 ->Get(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5261, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5259 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5261, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5260 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5261, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5261 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
context->Global() ->Get(context.local(), prop) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "13" " " "=="
" " "context->Global() ->Get(context.local(), prop) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5261, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5262 CHECK_EQ(v8::DontDelete, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::DontDelete
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::DontDelete" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5264, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5263 ->GetPropertyAttributes(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::DontDelete
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::DontDelete" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5264, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5264 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::DontDelete
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::DontDelete" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5264, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5265 // dont-enum
5266 prop = v8_str("dont_enum");
5267 context->Global()
5268 ->DefineOwnProperty(context.local(), prop, v8_num(28), v8::DontEnum)
5269 .FromJust();
5270 CHECK_EQ(v8::DontEnum, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::DontEnum
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::DontEnum" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5272, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5271 ->GetPropertyAttributes(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::DontEnum
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::DontEnum" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5272, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5272 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::DontEnum
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::DontEnum" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5272, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5273 // absent
5274 prop = v8_str("absent");
5275 CHECK_EQ(v8::None, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5277, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5276 ->GetPropertyAttributes(context.local(), prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5277, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5277 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5277, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5278 Local<Value> fake_prop = v8_num(1);
5279 CHECK_EQ(v8::None, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), fake_prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), fake_prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5281, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5280 ->GetPropertyAttributes(context.local(), fake_prop)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), fake_prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), fake_prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5281, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5281 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::None
), (context->Global() ->GetPropertyAttributes(context.local
(), fake_prop) .FromJust()), "v8::None" " " "==" " " "context->Global() ->GetPropertyAttributes(context.local(), fake_prop) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5281, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5282 // exception
5283 TryCatch try_catch(context->GetIsolate());
5284 Local<Value> exception =
5285 CompileRun("({ toString: function() { throw 'exception';} })");
5286 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->GetPropertyAttributes
(context.local(), exception) .IsNothing())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 5288, "Check failed: %s.", "context->Global() ->GetPropertyAttributes(context.local(), exception) .IsNothing()"
); } } while (0)
5287 ->GetPropertyAttributes(context.local(), exception)do { if ((__builtin_expect(!!(!(context->Global() ->GetPropertyAttributes
(context.local(), exception) .IsNothing())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 5288, "Check failed: %s.", "context->Global() ->GetPropertyAttributes(context.local(), exception) .IsNothing()"
); } } while (0)
5288 .IsNothing())do { if ((__builtin_expect(!!(!(context->Global() ->GetPropertyAttributes
(context.local(), exception) .IsNothing())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 5288, "Check failed: %s.", "context->Global() ->GetPropertyAttributes(context.local(), exception) .IsNothing()"
); } } while (0)
;
5289 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 5289, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
5290 String::Utf8Value exception_value(try_catch.Exception());
5291 CHECK_EQ(0, strcmp("exception", *exception_value))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("exception", *exception_value)), "0" " " "==" " " "strcmp(\"exception\", *exception_value)"
)) { V8_Fatal("../test/cctest/test-api.cc", 5291, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5292 try_catch.Reset();
5293}
5294
5295
5296THREADED_TEST(Array)static void TestArray(); RegisterThreadedTest register_Array(
TestArray, "Array"); static void TestArray(); CcTest register_test_Array
(TestArray, "../test/cctest/test-api.cc", "Array", __null, true
, true); static void TestArray()
{
5297 LocalContext context;
5298 v8::HandleScope scope(context->GetIsolate());
5299 Local<v8::Array> array = v8::Array::New(context->GetIsolate());
5300 CHECK_EQ(0u, array->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
array->Length()), "0u" " " "==" " " "array->Length()"))
{ V8_Fatal("../test/cctest/test-api.cc", 5300, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5301 CHECK(array->Get(context.local(), 0).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(array->Get(context.local()
, 0).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5301, "Check failed: %s.", "array->Get(context.local(), 0).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
5302 CHECK(!array->Has(context.local(), 0).FromJust())do { if ((__builtin_expect(!!(!(!array->Has(context.local(
), 0).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5302, "Check failed: %s.", "!array->Has(context.local(), 0).FromJust()"
); } } while (0)
;
5303 CHECK(array->Get(context.local(), 100).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(array->Get(context.local()
, 100).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 5303, "Check failed: %s.", "array->Get(context.local(), 100).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
5304 CHECK(!array->Has(context.local(), 100).FromJust())do { if ((__builtin_expect(!!(!(!array->Has(context.local(
), 100).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5304, "Check failed: %s.", "!array->Has(context.local(), 100).FromJust()"
); } } while (0)
;
5305 CHECK(array->Set(context.local(), 2, v8_num(7)).FromJust())do { if ((__builtin_expect(!!(!(array->Set(context.local()
, 2, v8_num(7)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5305, "Check failed: %s.", "array->Set(context.local(), 2, v8_num(7)).FromJust()"
); } } while (0)
;
5306 CHECK_EQ(3u, array->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3u), (
array->Length()), "3u" " " "==" " " "array->Length()"))
{ V8_Fatal("../test/cctest/test-api.cc", 5306, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5307 CHECK(!array->Has(context.local(), 0).FromJust())do { if ((__builtin_expect(!!(!(!array->Has(context.local(
), 0).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5307, "Check failed: %s.", "!array->Has(context.local(), 0).FromJust()"
); } } while (0)
;
5308 CHECK(!array->Has(context.local(), 1).FromJust())do { if ((__builtin_expect(!!(!(!array->Has(context.local(
), 1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5308, "Check failed: %s.", "!array->Has(context.local(), 1).FromJust()"
); } } while (0)
;
5309 CHECK(array->Has(context.local(), 2).FromJust())do { if ((__builtin_expect(!!(!(array->Has(context.local()
, 2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5309, "Check failed: %s.", "array->Has(context.local(), 2).FromJust()"
); } } while (0)
;
5310 CHECK_EQ(7, array->Get(context.local(), 2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (array
->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "7" " " "==" " " "array->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5313, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5311 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (array
->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "7" " " "==" " " "array->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5313, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5312 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (array
->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "7" " " "==" " " "array->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5313, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5313 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (array
->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "7" " " "==" " " "array->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5313, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5314 Local<Value> obj = CompileRun("[1, 2, 3]");
5315 Local<v8::Array> arr = obj.As<v8::Array>();
5316 CHECK_EQ(3u, arr->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3u), (
arr->Length()), "3u" " " "==" " " "arr->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5316, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5317 CHECK_EQ(1, arr->Get(context.local(), 0)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (arr
->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1" " " "==" " " "arr->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5320, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5318 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (arr
->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1" " " "==" " " "arr->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5320, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5319 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (arr
->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1" " " "==" " " "arr->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5320, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5320 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (arr
->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1" " " "==" " " "arr->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5320, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5321 CHECK_EQ(2, arr->Get(context.local(), 1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (arr
->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "2" " " "==" " " "arr->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5324, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5322 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (arr
->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "2" " " "==" " " "arr->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5324, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5323 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (arr
->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "2" " " "==" " " "arr->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5324, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5324 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (arr
->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "2" " " "==" " " "arr->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5324, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5325 CHECK_EQ(3, arr->Get(context.local(), 2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (arr
->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "3" " " "==" " " "arr->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5328, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5326 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (arr
->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "3" " " "==" " " "arr->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5328, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5327 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (arr
->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "3" " " "==" " " "arr->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5328, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5328 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (arr
->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "3" " " "==" " " "arr->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5328, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5329 array = v8::Array::New(context->GetIsolate(), 27);
5330 CHECK_EQ(27u, array->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (27u), (
array->Length()), "27u" " " "==" " " "array->Length()")
) { V8_Fatal("../test/cctest/test-api.cc", 5330, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5331 array = v8::Array::New(context->GetIsolate(), -27);
5332 CHECK_EQ(0u, array->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
array->Length()), "0u" " " "==" " " "array->Length()"))
{ V8_Fatal("../test/cctest/test-api.cc", 5332, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5333}
5334
5335
5336void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) {
5337 v8::EscapableHandleScope scope(args.GetIsolate());
5338 ApiTestFuzzer::Fuzz();
5339 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length());
5340 for (int i = 0; i < args.Length(); i++) {
5341 CHECK(result->Set(CcTest::isolate()->GetCurrentContext(), i, args[i])do { if ((__builtin_expect(!!(!(result->Set(CcTest::isolate
()->GetCurrentContext(), i, args[i]) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5342, "Check failed: %s."
, "result->Set(CcTest::isolate()->GetCurrentContext(), i, args[i]) .FromJust()"
); } } while (0)
5342 .FromJust())do { if ((__builtin_expect(!!(!(result->Set(CcTest::isolate
()->GetCurrentContext(), i, args[i]) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5342, "Check failed: %s."
, "result->Set(CcTest::isolate()->GetCurrentContext(), i, args[i]) .FromJust()"
); } } while (0)
;
5343 }
5344 args.GetReturnValue().Set(scope.Escape(result));
5345}
5346
5347
5348THREADED_TEST(Vector)static void TestVector(); RegisterThreadedTest register_Vector
(TestVector, "Vector"); static void TestVector(); CcTest register_test_Vector
(TestVector, "../test/cctest/test-api.cc", "Vector", __null, true
, true); static void TestVector()
{
5349 v8::Isolate* isolate = CcTest::isolate();
5350 v8::HandleScope scope(isolate);
5351 Local<ObjectTemplate> global = ObjectTemplate::New(isolate);
5352 global->Set(v8_str("f"), v8::FunctionTemplate::New(isolate, HandleF));
5353 LocalContext context(0, global);
5354
5355 const char* fun = "f()";
5356 Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>();
5357 CHECK_EQ(0u, a0->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
a0->Length()), "0u" " " "==" " " "a0->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5357, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5358
5359 const char* fun2 = "f(11)";
5360 Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>();
5361 CHECK_EQ(1u, a1->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
a1->Length()), "1u" " " "==" " " "a1->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5361, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5362 CHECK_EQ(11, a1->Get(context.local(), 0)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (11), (
a1->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "11" " " "==" " " "a1->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5365, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5363 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (11), (
a1->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "11" " " "==" " " "a1->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5365, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5364 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (11), (
a1->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "11" " " "==" " " "a1->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5365, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5365 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (11), (
a1->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "11" " " "==" " " "a1->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5365, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5366
5367 const char* fun3 = "f(12, 13)";
5368 Local<v8::Array> a2 = CompileRun(fun3).As<v8::Array>();
5369 CHECK_EQ(2u, a2->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
a2->Length()), "2u" " " "==" " " "a2->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5369, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5370 CHECK_EQ(12, a2->Get(context.local(), 0)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
a2->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "12" " " "==" " " "a2->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5373, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5371 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
a2->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "12" " " "==" " " "a2->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5373, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5372 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
a2->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "12" " " "==" " " "a2->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5373, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5373 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
a2->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "12" " " "==" " " "a2->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5373, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5374 CHECK_EQ(13, a2->Get(context.local(), 1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
a2->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "13" " " "==" " " "a2->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5377, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5375 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
a2->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "13" " " "==" " " "a2->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5377, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5376 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
a2->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "13" " " "==" " " "a2->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5377, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5377 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
a2->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "13" " " "==" " " "a2->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5377, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5378
5379 const char* fun4 = "f(14, 15, 16)";
5380 Local<v8::Array> a3 = CompileRun(fun4).As<v8::Array>();
5381 CHECK_EQ(3u, a3->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3u), (
a3->Length()), "3u" " " "==" " " "a3->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5381, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5382 CHECK_EQ(14, a3->Get(context.local(), 0)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (14), (
a3->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "14" " " "==" " " "a3->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5385, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5383 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (14), (
a3->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "14" " " "==" " " "a3->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5385, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5384 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (14), (
a3->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "14" " " "==" " " "a3->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5385, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5385 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (14), (
a3->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "14" " " "==" " " "a3->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5385, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5386 CHECK_EQ(15, a3->Get(context.local(), 1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15), (
a3->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "15" " " "==" " " "a3->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5389, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5387 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15), (
a3->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "15" " " "==" " " "a3->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5389, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5388 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15), (
a3->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "15" " " "==" " " "a3->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5389, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5389 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (15), (
a3->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "15" " " "==" " " "a3->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5389, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5390 CHECK_EQ(16, a3->Get(context.local(), 2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16), (
a3->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "16" " " "==" " " "a3->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5393, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5391 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16), (
a3->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "16" " " "==" " " "a3->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5393, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5392 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16), (
a3->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "16" " " "==" " " "a3->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5393, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5393 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16), (
a3->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "16" " " "==" " " "a3->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5393, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5394
5395 const char* fun5 = "f(17, 18, 19, 20)";
5396 Local<v8::Array> a4 = CompileRun(fun5).As<v8::Array>();
5397 CHECK_EQ(4u, a4->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4u), (
a4->Length()), "4u" " " "==" " " "a4->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5397, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5398 CHECK_EQ(17, a4->Get(context.local(), 0)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17), (
a4->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "17" " " "==" " " "a4->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5401, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5399 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17), (
a4->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "17" " " "==" " " "a4->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5401, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5400 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17), (
a4->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "17" " " "==" " " "a4->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5401, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5401 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17), (
a4->Get(context.local(), 0) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "17" " " "==" " " "a4->Get(context.local(), 0) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5401, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5402 CHECK_EQ(18, a4->Get(context.local(), 1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (18), (
a4->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "18" " " "==" " " "a4->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5405, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5403 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (18), (
a4->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "18" " " "==" " " "a4->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5405, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5404 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (18), (
a4->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "18" " " "==" " " "a4->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5405, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5405 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (18), (
a4->Get(context.local(), 1) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "18" " " "==" " " "a4->Get(context.local(), 1) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5405, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5406 CHECK_EQ(19, a4->Get(context.local(), 2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (19), (
a4->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "19" " " "==" " " "a4->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5409, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5407 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (19), (
a4->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "19" " " "==" " " "a4->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5409, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5408 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (19), (
a4->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "19" " " "==" " " "a4->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5409, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5409 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (19), (
a4->Get(context.local(), 2) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "19" " " "==" " " "a4->Get(context.local(), 2) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5409, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5410 CHECK_EQ(20, a4->Get(context.local(), 3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (20), (
a4->Get(context.local(), 3) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "20" " " "==" " " "a4->Get(context.local(), 3) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5413, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5411 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (20), (
a4->Get(context.local(), 3) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "20" " " "==" " " "a4->Get(context.local(), 3) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5413, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5412 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (20), (
a4->Get(context.local(), 3) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "20" " " "==" " " "a4->Get(context.local(), 3) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5413, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5413 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (20), (
a4->Get(context.local(), 3) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "20" " " "==" " " "a4->Get(context.local(), 3) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5413, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5414}
5415
5416
5417THREADED_TEST(FunctionCall)static void TestFunctionCall(); RegisterThreadedTest register_FunctionCall
(TestFunctionCall, "FunctionCall"); static void TestFunctionCall
(); CcTest register_test_FunctionCall(TestFunctionCall, "../test/cctest/test-api.cc"
, "FunctionCall", __null, true, true); static void TestFunctionCall
()
{
5418 LocalContext context;
5419 v8::Isolate* isolate = context->GetIsolate();
5420 v8::HandleScope scope(isolate);
5421 CompileRun(
5422 "function Foo() {"
5423 " var result = [];"
5424 " for (var i = 0; i < arguments.length; i++) {"
5425 " result.push(arguments[i]);"
5426 " }"
5427 " return result;"
5428 "}"
5429 "function ReturnThisSloppy() {"
5430 " return this;"
5431 "}"
5432 "function ReturnThisStrict() {"
5433 " 'use strict';"
5434 " return this;"
5435 "}");
5436 Local<Function> Foo = Local<Function>::Cast(
5437 context->Global()->Get(context.local(), v8_str("Foo")).ToLocalChecked());
5438 Local<Function> ReturnThisSloppy = Local<Function>::Cast(
5439 context->Global()
5440 ->Get(context.local(), v8_str("ReturnThisSloppy"))
5441 .ToLocalChecked());
5442 Local<Function> ReturnThisStrict = Local<Function>::Cast(
5443 context->Global()
5444 ->Get(context.local(), v8_str("ReturnThisStrict"))
5445 .ToLocalChecked());
5446
5447 v8::Local<Value>* args0 = NULL__null;
5448 Local<v8::Array> a0 = Local<v8::Array>::Cast(
5449 Foo->Call(context.local(), Foo, 0, args0).ToLocalChecked());
5450 CHECK_EQ(0u, a0->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
a0->Length()), "0u" " " "==" " " "a0->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5450, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5451
5452 v8::Local<Value> args1[] = {v8_num(1.1)};
5453 Local<v8::Array> a1 = Local<v8::Array>::Cast(
5454 Foo->Call(context.local(), Foo, 1, args1).ToLocalChecked());
5455 CHECK_EQ(1u, a1->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
a1->Length()), "1u" " " "==" " " "a1->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5455, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5456 CHECK_EQ(1.1, a1->Get(context.local(), v8::Integer::New(isolate, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.1), (
a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "1.1" " " "=="
" " "a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5459, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5457 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.1), (
a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "1.1" " " "=="
" " "a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5459, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5458 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.1), (
a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "1.1" " " "=="
" " "a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5459, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5459 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.1), (
a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "1.1" " " "=="
" " "a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5459, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5460
5461 v8::Local<Value> args2[] = {v8_num(2.2), v8_num(3.3)};
5462 Local<v8::Array> a2 = Local<v8::Array>::Cast(
5463 Foo->Call(context.local(), Foo, 2, args2).ToLocalChecked());
5464 CHECK_EQ(2u, a2->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
a2->Length()), "2u" " " "==" " " "a2->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5464, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5465 CHECK_EQ(2.2, a2->Get(context.local(), v8::Integer::New(isolate, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2.2), (
a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "2.2" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5468, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5466 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2.2), (
a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "2.2" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5468, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5467 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2.2), (
a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "2.2" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5468, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5468 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2.2), (
a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "2.2" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5468, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5469 CHECK_EQ(3.3, a2->Get(context.local(), v8::Integer::New(isolate, 1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.3), (
a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "3.3" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5472, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5470 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.3), (
a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "3.3" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5472, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5471 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.3), (
a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "3.3" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5472, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5472 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.3), (
a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "3.3" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5472, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5473
5474 v8::Local<Value> args3[] = {v8_num(4.4), v8_num(5.5), v8_num(6.6)};
5475 Local<v8::Array> a3 = Local<v8::Array>::Cast(
5476 Foo->Call(context.local(), Foo, 3, args3).ToLocalChecked());
5477 CHECK_EQ(3u, a3->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3u), (
a3->Length()), "3u" " " "==" " " "a3->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5477, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5478 CHECK_EQ(4.4, a3->Get(context.local(), v8::Integer::New(isolate, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4.4), (
a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "4.4" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5481, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5479 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4.4), (
a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "4.4" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5481, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5480 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4.4), (
a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "4.4" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5481, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5481 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4.4), (
a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "4.4" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5481, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5482 CHECK_EQ(5.5, a3->Get(context.local(), v8::Integer::New(isolate, 1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.5), (
a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "5.5" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5483 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.5), (
a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "5.5" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5484 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.5), (
a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "5.5" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5485 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.5), (
a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "5.5" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5486 CHECK_EQ(6.6, a3->Get(context.local(), v8::Integer::New(isolate, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.6), (
a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "6.6" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5489, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5487 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.6), (
a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "6.6" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5489, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5488 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.6), (
a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "6.6" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5489, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5489 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.6), (
a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "6.6" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5489, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5490
5491 v8::Local<Value> args4[] = {v8_num(7.7), v8_num(8.8), v8_num(9.9),
5492 v8_num(10.11)};
5493 Local<v8::Array> a4 = Local<v8::Array>::Cast(
5494 Foo->Call(context.local(), Foo, 4, args4).ToLocalChecked());
5495 CHECK_EQ(4u, a4->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4u), (
a4->Length()), "4u" " " "==" " " "a4->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5495, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5496 CHECK_EQ(7.7, a4->Get(context.local(), v8::Integer::New(isolate, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.7), (
a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "7.7" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5499, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5497 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.7), (
a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "7.7" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5499, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5498 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.7), (
a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "7.7" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5499, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5499 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.7), (
a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "7.7" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5499, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5500 CHECK_EQ(8.8, a4->Get(context.local(), v8::Integer::New(isolate, 1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8.8), (
a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "8.8" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5503, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5501 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8.8), (
a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "8.8" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5503, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5502 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8.8), (
a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "8.8" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5503, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5503 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8.8), (
a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "8.8" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5503, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5504 CHECK_EQ(9.9, a4->Get(context.local(), v8::Integer::New(isolate, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9.9), (
a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "9.9" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5507, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5505 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9.9), (
a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "9.9" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5507, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5506 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9.9), (
a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "9.9" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5507, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5507 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9.9), (
a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "9.9" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5507, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5508 CHECK_EQ(10.11, a4->Get(context.local(), v8::Integer::New(isolate, 3))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.11)
, (a4->Get(context.local(), v8::Integer::New(isolate, 3)) .
ToLocalChecked() ->NumberValue(context.local()) .FromJust(
)), "10.11" " " "==" " " "a4->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5511, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5509 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.11)
, (a4->Get(context.local(), v8::Integer::New(isolate, 3)) .
ToLocalChecked() ->NumberValue(context.local()) .FromJust(
)), "10.11" " " "==" " " "a4->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5511, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5510 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.11)
, (a4->Get(context.local(), v8::Integer::New(isolate, 3)) .
ToLocalChecked() ->NumberValue(context.local()) .FromJust(
)), "10.11" " " "==" " " "a4->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5511, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5511 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.11)
, (a4->Get(context.local(), v8::Integer::New(isolate, 3)) .
ToLocalChecked() ->NumberValue(context.local()) .FromJust(
)), "10.11" " " "==" " " "a4->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5511, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5512
5513 Local<v8::Value> r1 =
5514 ReturnThisSloppy->Call(context.local(), v8::Undefined(isolate), 0, NULL__null)
5515 .ToLocalChecked();
5516 CHECK(r1->StrictEquals(context->Global()))do { if ((__builtin_expect(!!(!(r1->StrictEquals(context->
Global()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5516
, "Check failed: %s.", "r1->StrictEquals(context->Global())"
); } } while (0)
;
5517 Local<v8::Value> r2 =
5518 ReturnThisSloppy->Call(context.local(), v8::Null(isolate), 0, NULL__null)
5519 .ToLocalChecked();
5520 CHECK(r2->StrictEquals(context->Global()))do { if ((__builtin_expect(!!(!(r2->StrictEquals(context->
Global()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5520
, "Check failed: %s.", "r2->StrictEquals(context->Global())"
); } } while (0)
;
5521 Local<v8::Value> r3 =
5522 ReturnThisSloppy->Call(context.local(), v8_num(42), 0, NULL__null)
5523 .ToLocalChecked();
5524 CHECK(r3->IsNumberObject())do { if ((__builtin_expect(!!(!(r3->IsNumberObject())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 5524, "Check failed: %s."
, "r3->IsNumberObject()"); } } while (0)
;
5525 CHECK_EQ(42.0, r3.As<v8::NumberObject>()->ValueOf())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(r3.As<v8::NumberObject>()->ValueOf()), "42.0" " " "=="
" " "r3.As<v8::NumberObject>()->ValueOf()")) { V8_Fatal
("../test/cctest/test-api.cc", 5525, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5526 Local<v8::Value> r4 =
5527 ReturnThisSloppy->Call(context.local(), v8_str("hello"), 0, NULL__null)
5528 .ToLocalChecked();
5529 CHECK(r4->IsStringObject())do { if ((__builtin_expect(!!(!(r4->IsStringObject())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 5529, "Check failed: %s."
, "r4->IsStringObject()"); } } while (0)
;
5530 CHECK(r4.As<v8::StringObject>()->ValueOf()->StrictEquals(v8_str("hello")))do { if ((__builtin_expect(!!(!(r4.As<v8::StringObject>
()->ValueOf()->StrictEquals(v8_str("hello")))), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5530, "Check failed: %s.", "r4.As<v8::StringObject>()->ValueOf()->StrictEquals(v8_str(\"hello\"))"
); } } while (0)
;
5531 Local<v8::Value> r5 =
5532 ReturnThisSloppy->Call(context.local(), v8::True(isolate), 0, NULL__null)
5533 .ToLocalChecked();
5534 CHECK(r5->IsBooleanObject())do { if ((__builtin_expect(!!(!(r5->IsBooleanObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5534, "Check failed: %s."
, "r5->IsBooleanObject()"); } } while (0)
;
5535 CHECK(r5.As<v8::BooleanObject>()->ValueOf())do { if ((__builtin_expect(!!(!(r5.As<v8::BooleanObject>
()->ValueOf())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5535, "Check failed: %s.", "r5.As<v8::BooleanObject>()->ValueOf()"
); } } while (0)
;
5536
5537 Local<v8::Value> r6 =
5538 ReturnThisStrict->Call(context.local(), v8::Undefined(isolate), 0, NULL__null)
5539 .ToLocalChecked();
5540 CHECK(r6->IsUndefined())do { if ((__builtin_expect(!!(!(r6->IsUndefined())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5540, "Check failed: %s."
, "r6->IsUndefined()"); } } while (0)
;
5541 Local<v8::Value> r7 =
5542 ReturnThisStrict->Call(context.local(), v8::Null(isolate), 0, NULL__null)
5543 .ToLocalChecked();
5544 CHECK(r7->IsNull())do { if ((__builtin_expect(!!(!(r7->IsNull())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5544, "Check failed: %s.", "r7->IsNull()"
); } } while (0)
;
5545 Local<v8::Value> r8 =
5546 ReturnThisStrict->Call(context.local(), v8_num(42), 0, NULL__null)
5547 .ToLocalChecked();
5548 CHECK(r8->StrictEquals(v8_num(42)))do { if ((__builtin_expect(!!(!(r8->StrictEquals(v8_num(42
)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5548, "Check failed: %s."
, "r8->StrictEquals(v8_num(42))"); } } while (0)
;
5549 Local<v8::Value> r9 =
5550 ReturnThisStrict->Call(context.local(), v8_str("hello"), 0, NULL__null)
5551 .ToLocalChecked();
5552 CHECK(r9->StrictEquals(v8_str("hello")))do { if ((__builtin_expect(!!(!(r9->StrictEquals(v8_str("hello"
)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5552, "Check failed: %s."
, "r9->StrictEquals(v8_str(\"hello\"))"); } } while (0)
;
5553 Local<v8::Value> r10 =
5554 ReturnThisStrict->Call(context.local(), v8::True(isolate), 0, NULL__null)
5555 .ToLocalChecked();
5556 CHECK(r10->StrictEquals(v8::True(isolate)))do { if ((__builtin_expect(!!(!(r10->StrictEquals(v8::True
(isolate)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5556
, "Check failed: %s.", "r10->StrictEquals(v8::True(isolate))"
); } } while (0)
;
5557}
5558
5559
5560THREADED_TEST(ConstructCall)static void TestConstructCall(); RegisterThreadedTest register_ConstructCall
(TestConstructCall, "ConstructCall"); static void TestConstructCall
(); CcTest register_test_ConstructCall(TestConstructCall, "../test/cctest/test-api.cc"
, "ConstructCall", __null, true, true); static void TestConstructCall
()
{
5561 LocalContext context;
5562 v8::Isolate* isolate = context->GetIsolate();
5563 v8::HandleScope scope(isolate);
5564 CompileRun(
5565 "function Foo() {"
5566 " var result = [];"
5567 " for (var i = 0; i < arguments.length; i++) {"
5568 " result.push(arguments[i]);"
5569 " }"
5570 " return result;"
5571 "}");
5572 Local<Function> Foo = Local<Function>::Cast(
5573 context->Global()->Get(context.local(), v8_str("Foo")).ToLocalChecked());
5574
5575 v8::Local<Value>* args0 = NULL__null;
5576 Local<v8::Array> a0 = Local<v8::Array>::Cast(
5577 Foo->NewInstance(context.local(), 0, args0).ToLocalChecked());
5578 CHECK_EQ(0u, a0->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
a0->Length()), "0u" " " "==" " " "a0->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5578, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5579
5580 v8::Local<Value> args1[] = {v8_num(1.1)};
5581 Local<v8::Array> a1 = Local<v8::Array>::Cast(
5582 Foo->NewInstance(context.local(), 1, args1).ToLocalChecked());
5583 CHECK_EQ(1u, a1->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
a1->Length()), "1u" " " "==" " " "a1->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5583, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5584 CHECK_EQ(1.1, a1->Get(context.local(), v8::Integer::New(isolate, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.1), (
a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "1.1" " " "=="
" " "a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5587, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5585 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.1), (
a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "1.1" " " "=="
" " "a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5587, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5586 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.1), (
a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "1.1" " " "=="
" " "a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5587, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5587 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.1), (
a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "1.1" " " "=="
" " "a1->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5587, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5588
5589 v8::Local<Value> args2[] = {v8_num(2.2), v8_num(3.3)};
5590 Local<v8::Array> a2 = Local<v8::Array>::Cast(
5591 Foo->NewInstance(context.local(), 2, args2).ToLocalChecked());
5592 CHECK_EQ(2u, a2->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
a2->Length()), "2u" " " "==" " " "a2->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5592, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5593 CHECK_EQ(2.2, a2->Get(context.local(), v8::Integer::New(isolate, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2.2), (
a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "2.2" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5596, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5594 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2.2), (
a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "2.2" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5596, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5595 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2.2), (
a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "2.2" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5596, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5596 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2.2), (
a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "2.2" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5596, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5597 CHECK_EQ(3.3, a2->Get(context.local(), v8::Integer::New(isolate, 1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.3), (
a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "3.3" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5600, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5598 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.3), (
a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "3.3" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5600, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5599 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.3), (
a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "3.3" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5600, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5600 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3.3), (
a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "3.3" " " "=="
" " "a2->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5600, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5601
5602 v8::Local<Value> args3[] = {v8_num(4.4), v8_num(5.5), v8_num(6.6)};
5603 Local<v8::Array> a3 = Local<v8::Array>::Cast(
5604 Foo->NewInstance(context.local(), 3, args3).ToLocalChecked());
5605 CHECK_EQ(3u, a3->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3u), (
a3->Length()), "3u" " " "==" " " "a3->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5605, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5606 CHECK_EQ(4.4, a3->Get(context.local(), v8::Integer::New(isolate, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4.4), (
a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "4.4" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5609, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5607 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4.4), (
a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "4.4" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5609, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5608 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4.4), (
a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "4.4" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5609, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5609 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4.4), (
a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "4.4" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5609, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5610 CHECK_EQ(5.5, a3->Get(context.local(), v8::Integer::New(isolate, 1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.5), (
a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "5.5" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5613, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5611 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.5), (
a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "5.5" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5613, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5612 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.5), (
a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "5.5" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5613, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5613 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5.5), (
a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "5.5" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5613, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5614 CHECK_EQ(6.6, a3->Get(context.local(), v8::Integer::New(isolate, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.6), (
a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "6.6" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5617, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5615 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.6), (
a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "6.6" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5617, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5616 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.6), (
a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "6.6" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5617, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5617 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6.6), (
a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "6.6" " " "=="
" " "a3->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5617, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5618
5619 v8::Local<Value> args4[] = {v8_num(7.7), v8_num(8.8), v8_num(9.9),
5620 v8_num(10.11)};
5621 Local<v8::Array> a4 = Local<v8::Array>::Cast(
5622 Foo->NewInstance(context.local(), 4, args4).ToLocalChecked());
5623 CHECK_EQ(4u, a4->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4u), (
a4->Length()), "4u" " " "==" " " "a4->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 5623, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
5624 CHECK_EQ(7.7, a4->Get(context.local(), v8::Integer::New(isolate, 0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.7), (
a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "7.7" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5627, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5625 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.7), (
a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "7.7" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5627, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5626 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.7), (
a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "7.7" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5627, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5627 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7.7), (
a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "7.7" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5627, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5628 CHECK_EQ(8.8, a4->Get(context.local(), v8::Integer::New(isolate, 1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8.8), (
a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "8.8" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5631, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5629 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8.8), (
a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "8.8" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5631, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5630 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8.8), (
a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "8.8" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5631, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5631 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8.8), (
a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "8.8" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5631, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5632 CHECK_EQ(9.9, a4->Get(context.local(), v8::Integer::New(isolate, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9.9), (
a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "9.9" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5635, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5633 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9.9), (
a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "9.9" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5635, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5634 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9.9), (
a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "9.9" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5635, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5635 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9.9), (
a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->NumberValue(context.local()) .FromJust()), "9.9" " " "=="
" " "a4->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5635, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5636 CHECK_EQ(10.11, a4->Get(context.local(), v8::Integer::New(isolate, 3))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.11)
, (a4->Get(context.local(), v8::Integer::New(isolate, 3)) .
ToLocalChecked() ->NumberValue(context.local()) .FromJust(
)), "10.11" " " "==" " " "a4->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5639, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5637 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.11)
, (a4->Get(context.local(), v8::Integer::New(isolate, 3)) .
ToLocalChecked() ->NumberValue(context.local()) .FromJust(
)), "10.11" " " "==" " " "a4->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5639, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5638 ->NumberValue(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.11)
, (a4->Get(context.local(), v8::Integer::New(isolate, 3)) .
ToLocalChecked() ->NumberValue(context.local()) .FromJust(
)), "10.11" " " "==" " " "a4->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5639, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5639 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10.11)
, (a4->Get(context.local(), v8::Integer::New(isolate, 3)) .
ToLocalChecked() ->NumberValue(context.local()) .FromJust(
)), "10.11" " " "==" " " "a4->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->NumberValue(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5639, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5640}
5641
5642
5643THREADED_TEST(ConversionNumber)static void TestConversionNumber(); RegisterThreadedTest register_ConversionNumber
(TestConversionNumber, "ConversionNumber"); static void TestConversionNumber
(); CcTest register_test_ConversionNumber(TestConversionNumber
, "../test/cctest/test-api.cc", "ConversionNumber", __null, true
, true); static void TestConversionNumber()
{
5644 LocalContext env;
5645 v8::Isolate* isolate = env->GetIsolate();
5646 v8::HandleScope scope(isolate);
5647 // Very large number.
5648 CompileRun("var obj = Math.pow(2,32) * 1237;");
5649 Local<Value> obj =
5650 env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5651 CHECK_EQ(5312874545152.0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5312874545152.0
), (obj->ToNumber(env.local()).ToLocalChecked()->Value(
)), "5312874545152.0" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5652, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5652 obj->ToNumber(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5312874545152.0
), (obj->ToNumber(env.local()).ToLocalChecked()->Value(
)), "5312874545152.0" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5652, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5653 CHECK_EQ(0, obj->ToInt32(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (obj
->ToInt32(env.local()).ToLocalChecked()->Value()), "0" " "
"==" " " "obj->ToInt32(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5653, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5654 CHECK(0u ==do { if ((__builtin_expect(!!(!(0u == obj->ToUint32(env.local
()) .ToLocalChecked() ->Value())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5657, "Check failed: %s.", "0u == obj->ToUint32(env.local()) .ToLocalChecked() ->Value()"
); } } while (0)
5655 obj->ToUint32(env.local())do { if ((__builtin_expect(!!(!(0u == obj->ToUint32(env.local
()) .ToLocalChecked() ->Value())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5657, "Check failed: %s.", "0u == obj->ToUint32(env.local()) .ToLocalChecked() ->Value()"
); } } while (0)
5656 .ToLocalChecked()do { if ((__builtin_expect(!!(!(0u == obj->ToUint32(env.local
()) .ToLocalChecked() ->Value())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5657, "Check failed: %s.", "0u == obj->ToUint32(env.local()) .ToLocalChecked() ->Value()"
); } } while (0)
5657 ->Value())do { if ((__builtin_expect(!!(!(0u == obj->ToUint32(env.local
()) .ToLocalChecked() ->Value())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5657, "Check failed: %s.", "0u == obj->ToUint32(env.local()) .ToLocalChecked() ->Value()"
); } } while (0)
; // NOLINT - no CHECK_EQ for unsigned.
5658 // Large number.
5659 CompileRun("var obj = -1234567890123;");
5660 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5661 CHECK_EQ(-1234567890123.0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-1234567890123.0
), (obj->ToNumber(env.local()).ToLocalChecked()->Value(
)), "-1234567890123.0" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5662, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5662 obj->ToNumber(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-1234567890123.0
), (obj->ToNumber(env.local()).ToLocalChecked()->Value(
)), "-1234567890123.0" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5662, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5663 CHECK_EQ(-1912276171, obj->ToInt32(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-1912276171
), (obj->ToInt32(env.local()).ToLocalChecked()->Value()
), "-1912276171" " " "==" " " "obj->ToInt32(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5663, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5664 CHECK(2382691125u ==do { if ((__builtin_expect(!!(!(2382691125u == obj->ToUint32
(env.local()).ToLocalChecked()->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5665, "Check failed: %s.", "2382691125u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
5665 obj->ToUint32(env.local()).ToLocalChecked()->Value())do { if ((__builtin_expect(!!(!(2382691125u == obj->ToUint32
(env.local()).ToLocalChecked()->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5665, "Check failed: %s.", "2382691125u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
; // NOLINT
5666 // Small positive integer.
5667 CompileRun("var obj = 42;");
5668 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5669 CHECK_EQ(42.0, obj->ToNumber(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(obj->ToNumber(env.local()).ToLocalChecked()->Value())
, "42.0" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5669, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5670 CHECK_EQ(42, obj->ToInt32(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
obj->ToInt32(env.local()).ToLocalChecked()->Value()), "42"
" " "==" " " "obj->ToInt32(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5670, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5671 CHECK(42u == obj->ToUint32(env.local()).ToLocalChecked()->Value())do { if ((__builtin_expect(!!(!(42u == obj->ToUint32(env.local
()).ToLocalChecked()->Value())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5671, "Check failed: %s.", "42u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
; // NOLINT
5672 // Negative integer.
5673 CompileRun("var obj = -37;");
5674 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5675 CHECK_EQ(-37.0, obj->ToNumber(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-37.0)
, (obj->ToNumber(env.local()).ToLocalChecked()->Value()
), "-37.0" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5675, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5676 CHECK_EQ(-37, obj->ToInt32(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-37), (
obj->ToInt32(env.local()).ToLocalChecked()->Value()), "-37"
" " "==" " " "obj->ToInt32(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5676, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5677 CHECK(4294967259u ==do { if ((__builtin_expect(!!(!(4294967259u == obj->ToUint32
(env.local()).ToLocalChecked()->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5678, "Check failed: %s.", "4294967259u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
5678 obj->ToUint32(env.local()).ToLocalChecked()->Value())do { if ((__builtin_expect(!!(!(4294967259u == obj->ToUint32
(env.local()).ToLocalChecked()->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5678, "Check failed: %s.", "4294967259u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
; // NOLINT
5679 // Positive non-int32 integer.
5680 CompileRun("var obj = 0x81234567;");
5681 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5682 CHECK_EQ(2166572391.0, obj->ToNumber(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2166572391.0
), (obj->ToNumber(env.local()).ToLocalChecked()->Value(
)), "2166572391.0" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5682, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5683 CHECK_EQ(-2128394905, obj->ToInt32(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-2128394905
), (obj->ToInt32(env.local()).ToLocalChecked()->Value()
), "-2128394905" " " "==" " " "obj->ToInt32(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5683, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5684 CHECK(2166572391u ==do { if ((__builtin_expect(!!(!(2166572391u == obj->ToUint32
(env.local()).ToLocalChecked()->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5685, "Check failed: %s.", "2166572391u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
5685 obj->ToUint32(env.local()).ToLocalChecked()->Value())do { if ((__builtin_expect(!!(!(2166572391u == obj->ToUint32
(env.local()).ToLocalChecked()->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5685, "Check failed: %s.", "2166572391u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
; // NOLINT
5686 // Fraction.
5687 CompileRun("var obj = 42.3;");
5688 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5689 CHECK_EQ(42.3, obj->ToNumber(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.3),
(obj->ToNumber(env.local()).ToLocalChecked()->Value())
, "42.3" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5689, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5690 CHECK_EQ(42, obj->ToInt32(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
obj->ToInt32(env.local()).ToLocalChecked()->Value()), "42"
" " "==" " " "obj->ToInt32(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5690, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5691 CHECK(42u == obj->ToUint32(env.local()).ToLocalChecked()->Value())do { if ((__builtin_expect(!!(!(42u == obj->ToUint32(env.local
()).ToLocalChecked()->Value())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5691, "Check failed: %s.", "42u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
; // NOLINT
5692 // Large negative fraction.
5693 CompileRun("var obj = -5726623061.75;");
5694 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5695 CHECK_EQ(-5726623061.75,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-5726623061.75
), (obj->ToNumber(env.local()).ToLocalChecked()->Value(
)), "-5726623061.75" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5696, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
5696 obj->ToNumber(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-5726623061.75
), (obj->ToNumber(env.local()).ToLocalChecked()->Value(
)), "-5726623061.75" " " "==" " " "obj->ToNumber(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5696, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5697 CHECK_EQ(-1431655765, obj->ToInt32(env.local()).ToLocalChecked()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-1431655765
), (obj->ToInt32(env.local()).ToLocalChecked()->Value()
), "-1431655765" " " "==" " " "obj->ToInt32(env.local()).ToLocalChecked()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 5697, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5698 CHECK(2863311531u ==do { if ((__builtin_expect(!!(!(2863311531u == obj->ToUint32
(env.local()).ToLocalChecked()->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5699, "Check failed: %s.", "2863311531u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
5699 obj->ToUint32(env.local()).ToLocalChecked()->Value())do { if ((__builtin_expect(!!(!(2863311531u == obj->ToUint32
(env.local()).ToLocalChecked()->Value())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5699, "Check failed: %s.", "2863311531u == obj->ToUint32(env.local()).ToLocalChecked()->Value()"
); } } while (0)
; // NOLINT
5700}
5701
5702
5703THREADED_TEST(isNumberType)static void TestisNumberType(); RegisterThreadedTest register_isNumberType
(TestisNumberType, "isNumberType"); static void TestisNumberType
(); CcTest register_test_isNumberType(TestisNumberType, "../test/cctest/test-api.cc"
, "isNumberType", __null, true, true); static void TestisNumberType
()
{
5704 LocalContext env;
5705 v8::HandleScope scope(env->GetIsolate());
5706 // Very large number.
5707 CompileRun("var obj = Math.pow(2,32) * 1237;");
5708 Local<Value> obj =
5709 env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5710 CHECK(!obj->IsInt32())do { if ((__builtin_expect(!!(!(!obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5710, "Check failed: %s.", "!obj->IsInt32()"
); } } while (0)
;
5711 CHECK(!obj->IsUint32())do { if ((__builtin_expect(!!(!(!obj->IsUint32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5711, "Check failed: %s."
, "!obj->IsUint32()"); } } while (0)
;
5712 // Large negative number.
5713 CompileRun("var obj = -1234567890123;");
5714 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5715 CHECK(!obj->IsInt32())do { if ((__builtin_expect(!!(!(!obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5715, "Check failed: %s.", "!obj->IsInt32()"
); } } while (0)
;
5716 CHECK(!obj->IsUint32())do { if ((__builtin_expect(!!(!(!obj->IsUint32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5716, "Check failed: %s."
, "!obj->IsUint32()"); } } while (0)
;
5717 // Small positive integer.
5718 CompileRun("var obj = 42;");
5719 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5720 CHECK(obj->IsInt32())do { if ((__builtin_expect(!!(!(obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5720, "Check failed: %s.", "obj->IsInt32()"
); } } while (0)
;
5721 CHECK(obj->IsUint32())do { if ((__builtin_expect(!!(!(obj->IsUint32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5721, "Check failed: %s.", "obj->IsUint32()"
); } } while (0)
;
5722 // Negative integer.
5723 CompileRun("var obj = -37;");
5724 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5725 CHECK(obj->IsInt32())do { if ((__builtin_expect(!!(!(obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5725, "Check failed: %s.", "obj->IsInt32()"
); } } while (0)
;
5726 CHECK(!obj->IsUint32())do { if ((__builtin_expect(!!(!(!obj->IsUint32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5726, "Check failed: %s."
, "!obj->IsUint32()"); } } while (0)
;
5727 // Positive non-int32 integer.
5728 CompileRun("var obj = 0x81234567;");
5729 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5730 CHECK(!obj->IsInt32())do { if ((__builtin_expect(!!(!(!obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5730, "Check failed: %s.", "!obj->IsInt32()"
); } } while (0)
;
5731 CHECK(obj->IsUint32())do { if ((__builtin_expect(!!(!(obj->IsUint32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5731, "Check failed: %s.", "obj->IsUint32()"
); } } while (0)
;
5732 // Fraction.
5733 CompileRun("var obj = 42.3;");
5734 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5735 CHECK(!obj->IsInt32())do { if ((__builtin_expect(!!(!(!obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5735, "Check failed: %s.", "!obj->IsInt32()"
); } } while (0)
;
5736 CHECK(!obj->IsUint32())do { if ((__builtin_expect(!!(!(!obj->IsUint32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5736, "Check failed: %s."
, "!obj->IsUint32()"); } } while (0)
;
5737 // Large negative fraction.
5738 CompileRun("var obj = -5726623061.75;");
5739 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5740 CHECK(!obj->IsInt32())do { if ((__builtin_expect(!!(!(!obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5740, "Check failed: %s.", "!obj->IsInt32()"
); } } while (0)
;
5741 CHECK(!obj->IsUint32())do { if ((__builtin_expect(!!(!(!obj->IsUint32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5741, "Check failed: %s."
, "!obj->IsUint32()"); } } while (0)
;
5742 // Positive zero
5743 CompileRun("var obj = 0.0;");
5744 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5745 CHECK(obj->IsInt32())do { if ((__builtin_expect(!!(!(obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5745, "Check failed: %s.", "obj->IsInt32()"
); } } while (0)
;
5746 CHECK(obj->IsUint32())do { if ((__builtin_expect(!!(!(obj->IsUint32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5746, "Check failed: %s.", "obj->IsUint32()"
); } } while (0)
;
5747 // Positive zero
5748 CompileRun("var obj = -0.0;");
5749 obj = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5750 CHECK(!obj->IsInt32())do { if ((__builtin_expect(!!(!(!obj->IsInt32())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 5750, "Check failed: %s.", "!obj->IsInt32()"
); } } while (0)
;
5751 CHECK(!obj->IsUint32())do { if ((__builtin_expect(!!(!(!obj->IsUint32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5751, "Check failed: %s."
, "!obj->IsUint32()"); } } while (0)
;
5752}
5753
5754
5755static void CheckUncle(v8::TryCatch* try_catch) {
5756 CHECK(try_catch->HasCaught())do { if ((__builtin_expect(!!(!(try_catch->HasCaught())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 5756, "Check failed: %s."
, "try_catch->HasCaught()"); } } while (0)
;
5757 String::Utf8Value str_value(try_catch->Exception());
5758 CHECK_EQ(0, strcmp(*str_value, "uncle?"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*str_value, "uncle?")), "0" " " "==" " " "strcmp(*str_value, \"uncle?\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 5758, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
5759 try_catch->Reset();
5760}
5761
5762
5763THREADED_TEST(ConversionException)static void TestConversionException(); RegisterThreadedTest register_ConversionException
(TestConversionException, "ConversionException"); static void
TestConversionException(); CcTest register_test_ConversionException
(TestConversionException, "../test/cctest/test-api.cc", "ConversionException"
, __null, true, true); static void TestConversionException()
{
5764 LocalContext env;
5765 v8::Isolate* isolate = env->GetIsolate();
5766 v8::HandleScope scope(isolate);
5767 CompileRun(
5768 "function TestClass() { };"
5769 "TestClass.prototype.toString = function () { throw 'uncle?'; };"
5770 "var obj = new TestClass();");
5771 Local<Value> obj =
5772 env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
5773
5774 v8::TryCatch try_catch(isolate);
5775
5776 CHECK(obj->ToString(env.local()).IsEmpty())do { if ((__builtin_expect(!!(!(obj->ToString(env.local())
.IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5776
, "Check failed: %s.", "obj->ToString(env.local()).IsEmpty()"
); } } while (0)
;
5777 CheckUncle(&try_catch);
5778
5779 CHECK(obj->ToNumber(env.local()).IsEmpty())do { if ((__builtin_expect(!!(!(obj->ToNumber(env.local())
.IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5779
, "Check failed: %s.", "obj->ToNumber(env.local()).IsEmpty()"
); } } while (0)
;
5780 CheckUncle(&try_catch);
5781
5782 CHECK(obj->ToInteger(env.local()).IsEmpty())do { if ((__builtin_expect(!!(!(obj->ToInteger(env.local()
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5782
, "Check failed: %s.", "obj->ToInteger(env.local()).IsEmpty()"
); } } while (0)
;
5783 CheckUncle(&try_catch);
5784
5785 CHECK(obj->ToUint32(env.local()).IsEmpty())do { if ((__builtin_expect(!!(!(obj->ToUint32(env.local())
.IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5785
, "Check failed: %s.", "obj->ToUint32(env.local()).IsEmpty()"
); } } while (0)
;
5786 CheckUncle(&try_catch);
5787
5788 CHECK(obj->ToInt32(env.local()).IsEmpty())do { if ((__builtin_expect(!!(!(obj->ToInt32(env.local()).
IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5788
, "Check failed: %s.", "obj->ToInt32(env.local()).IsEmpty()"
); } } while (0)
;
5789 CheckUncle(&try_catch);
5790
5791 CHECK(v8::Undefined(isolate)->ToObject(env.local()).IsEmpty())do { if ((__builtin_expect(!!(!(v8::Undefined(isolate)->ToObject
(env.local()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5791, "Check failed: %s.", "v8::Undefined(isolate)->ToObject(env.local()).IsEmpty()"
); } } while (0)
;
5792 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 5792, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
5793 try_catch.Reset();
5794
5795 CHECK(obj->Int32Value(env.local()).IsNothing())do { if ((__builtin_expect(!!(!(obj->Int32Value(env.local(
)).IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5795, "Check failed: %s.", "obj->Int32Value(env.local()).IsNothing()"
); } } while (0)
;
5796 CheckUncle(&try_catch);
5797
5798 CHECK(obj->Uint32Value(env.local()).IsNothing())do { if ((__builtin_expect(!!(!(obj->Uint32Value(env.local
()).IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5798, "Check failed: %s.", "obj->Uint32Value(env.local()).IsNothing()"
); } } while (0)
;
5799 CheckUncle(&try_catch);
5800
5801 CHECK(obj->NumberValue(env.local()).IsNothing())do { if ((__builtin_expect(!!(!(obj->NumberValue(env.local
()).IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5801, "Check failed: %s.", "obj->NumberValue(env.local()).IsNothing()"
); } } while (0)
;
5802 CheckUncle(&try_catch);
5803
5804 CHECK(obj->IntegerValue(env.local()).IsNothing())do { if ((__builtin_expect(!!(!(obj->IntegerValue(env.local
()).IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5804, "Check failed: %s.", "obj->IntegerValue(env.local()).IsNothing()"
); } } while (0)
;
5805 CheckUncle(&try_catch);
5806}
5807
5808
5809void ThrowFromC(const v8::FunctionCallbackInfo<v8::Value>& args) {
5810 ApiTestFuzzer::Fuzz();
5811 args.GetIsolate()->ThrowException(v8_str("konto"));
5812}
5813
5814
5815void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) {
5816 if (args.Length() < 1) {
5817 args.GetReturnValue().Set(false);
5818 return;
5819 }
5820 v8::HandleScope scope(args.GetIsolate());
5821 v8::TryCatch try_catch(args.GetIsolate());
5822 Local<Value> result =
5823 CompileRun(args[0]
5824 ->ToString(args.GetIsolate()->GetCurrentContext())
5825 .ToLocalChecked());
5826 CHECK(!try_catch.HasCaught() || result.IsEmpty())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught() || result
.IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 5826
, "Check failed: %s.", "!try_catch.HasCaught() || result.IsEmpty()"
); } } while (0)
;
5827 args.GetReturnValue().Set(try_catch.HasCaught());
5828}
5829
5830
5831THREADED_TEST(APICatch)static void TestAPICatch(); RegisterThreadedTest register_APICatch
(TestAPICatch, "APICatch"); static void TestAPICatch(); CcTest
register_test_APICatch(TestAPICatch, "../test/cctest/test-api.cc"
, "APICatch", __null, true, true); static void TestAPICatch()
{
5832 v8::Isolate* isolate = CcTest::isolate();
5833 v8::HandleScope scope(isolate);
5834 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
5835 templ->Set(v8_str("ThrowFromC"),
5836 v8::FunctionTemplate::New(isolate, ThrowFromC));
5837 LocalContext context(0, templ);
5838 CompileRun(
5839 "var thrown = false;"
5840 "try {"
5841 " ThrowFromC();"
5842 "} catch (e) {"
5843 " thrown = true;"
5844 "}");
5845 Local<Value> thrown = context->Global()
5846 ->Get(context.local(), v8_str("thrown"))
5847 .ToLocalChecked();
5848 CHECK(thrown->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(thrown->BooleanValue(context
.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5848, "Check failed: %s.", "thrown->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
5849}
5850
5851
5852THREADED_TEST(APIThrowTryCatch)static void TestAPIThrowTryCatch(); RegisterThreadedTest register_APIThrowTryCatch
(TestAPIThrowTryCatch, "APIThrowTryCatch"); static void TestAPIThrowTryCatch
(); CcTest register_test_APIThrowTryCatch(TestAPIThrowTryCatch
, "../test/cctest/test-api.cc", "APIThrowTryCatch", __null, true
, true); static void TestAPIThrowTryCatch()
{
5853 v8::Isolate* isolate = CcTest::isolate();
5854 v8::HandleScope scope(isolate);
5855 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
5856 templ->Set(v8_str("ThrowFromC"),
5857 v8::FunctionTemplate::New(isolate, ThrowFromC));
5858 LocalContext context(0, templ);
5859 v8::TryCatch try_catch(isolate);
5860 CompileRun("ThrowFromC();");
5861 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 5861, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
5862}
5863
5864
5865// Test that a try-finally block doesn't shadow a try-catch block
5866// when setting up an external handler.
5867//
5868// BUG(271): Some of the exception propagation does not work on the
5869// ARM simulator because the simulator separates the C++ stack and the
5870// JS stack. This test therefore fails on the simulator. The test is
5871// not threaded to allow the threading tests to run on the simulator.
5872TEST(TryCatchInTryFinally)static void TestTryCatchInTryFinally(); CcTest register_test_TryCatchInTryFinally
(TestTryCatchInTryFinally, "../test/cctest/test-api.cc", "TryCatchInTryFinally"
, __null, true, true); static void TestTryCatchInTryFinally()
{
5873 v8::Isolate* isolate = CcTest::isolate();
5874 v8::HandleScope scope(isolate);
5875 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
5876 templ->Set(v8_str("CCatcher"), v8::FunctionTemplate::New(isolate, CCatcher));
5877 LocalContext context(0, templ);
5878 Local<Value> result = CompileRun(
5879 "try {"
5880 " try {"
5881 " CCatcher('throw 7;');"
5882 " } finally {"
5883 " }"
5884 "} catch (e) {"
5885 "}");
5886 CHECK(result->IsTrue())do { if ((__builtin_expect(!!(!(result->IsTrue())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 5886, "Check failed: %s."
, "result->IsTrue()"); } } while (0)
;
5887}
5888
5889
5890static void check_custom_error_tostring(v8::Local<v8::Message> message,
5891 v8::Local<v8::Value> data) {
5892 const char* uncaught_error = "Uncaught MyError toString";
5893 CHECK(message->Get()do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5896, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5894 ->Equals(CcTest::isolate()->GetCurrentContext(),do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5896, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5895 v8_str(uncaught_error))do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5896, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5896 .FromJust())do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5896, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
;
5897}
5898
5899
5900TEST(CustomErrorToString)static void TestCustomErrorToString(); CcTest register_test_CustomErrorToString
(TestCustomErrorToString, "../test/cctest/test-api.cc", "CustomErrorToString"
, __null, true, true); static void TestCustomErrorToString()
{
5901 LocalContext context;
5902 v8::HandleScope scope(context->GetIsolate());
5903 context->GetIsolate()->AddMessageListener(check_custom_error_tostring);
5904 CompileRun(
5905 "function MyError(name, message) { "
5906 " this.name = name; "
5907 " this.message = message; "
5908 "} "
5909 "MyError.prototype = Object.create(Error.prototype); "
5910 "MyError.prototype.toString = function() { "
5911 " return 'MyError toString'; "
5912 "}; "
5913 "throw new MyError('my name', 'my message'); ");
5914 context->GetIsolate()->RemoveMessageListeners(check_custom_error_tostring);
5915}
5916
5917
5918static void check_custom_error_message(v8::Local<v8::Message> message,
5919 v8::Local<v8::Value> data) {
5920 const char* uncaught_error = "Uncaught MyError: my message";
5921 printf("%s\n", *v8::String::Utf8Value(message->Get()));
5922 CHECK(message->Get()do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5925, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5923 ->Equals(CcTest::isolate()->GetCurrentContext(),do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5925, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5924 v8_str(uncaught_error))do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5925, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5925 .FromJust())do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5925, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
;
5926}
5927
5928
5929TEST(CustomErrorMessage)static void TestCustomErrorMessage(); CcTest register_test_CustomErrorMessage
(TestCustomErrorMessage, "../test/cctest/test-api.cc", "CustomErrorMessage"
, __null, true, true); static void TestCustomErrorMessage()
{
5930 LocalContext context;
5931 v8::HandleScope scope(context->GetIsolate());
5932 context->GetIsolate()->AddMessageListener(check_custom_error_message);
5933
5934 // Handlebars.
5935 CompileRun(
5936 "function MyError(msg) { "
5937 " this.name = 'MyError'; "
5938 " this.message = msg; "
5939 "} "
5940 "MyError.prototype = new Error(); "
5941 "throw new MyError('my message'); ");
5942
5943 // Closure.
5944 CompileRun(
5945 "function MyError(msg) { "
5946 " this.name = 'MyError'; "
5947 " this.message = msg; "
5948 "} "
5949 "inherits = function(childCtor, parentCtor) { "
5950 " function tempCtor() {}; "
5951 " tempCtor.prototype = parentCtor.prototype; "
5952 " childCtor.superClass_ = parentCtor.prototype; "
5953 " childCtor.prototype = new tempCtor(); "
5954 " childCtor.prototype.constructor = childCtor; "
5955 "}; "
5956 "inherits(MyError, Error); "
5957 "throw new MyError('my message'); ");
5958
5959 // Object.create.
5960 CompileRun(
5961 "function MyError(msg) { "
5962 " this.name = 'MyError'; "
5963 " this.message = msg; "
5964 "} "
5965 "MyError.prototype = Object.create(Error.prototype); "
5966 "throw new MyError('my message'); ");
5967
5968 context->GetIsolate()->RemoveMessageListeners(check_custom_error_message);
5969}
5970
5971
5972static void check_custom_rethrowing_message(v8::Local<v8::Message> message,
5973 v8::Local<v8::Value> data) {
5974 const char* uncaught_error = "Uncaught exception";
5975 CHECK(message->Get()do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5978, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5976 ->Equals(CcTest::isolate()->GetCurrentContext(),do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5978, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5977 v8_str(uncaught_error))do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5978, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
5978 .FromJust())do { if ((__builtin_expect(!!(!(message->Get() ->Equals
(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 5978, "Check failed: %s.", "message->Get() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(uncaught_error)) .FromJust()"
); } } while (0)
;
5979}
5980
5981
5982TEST(CustomErrorRethrowsOnToString)static void TestCustomErrorRethrowsOnToString(); CcTest register_test_CustomErrorRethrowsOnToString
(TestCustomErrorRethrowsOnToString, "../test/cctest/test-api.cc"
, "CustomErrorRethrowsOnToString", __null, true, true); static
void TestCustomErrorRethrowsOnToString()
{
5983 LocalContext context;
5984 v8::HandleScope scope(context->GetIsolate());
5985 context->GetIsolate()->AddMessageListener(check_custom_rethrowing_message);
5986
5987 CompileRun(
5988 "var e = { toString: function() { throw e; } };"
5989 "try { throw e; } finally {}");
5990
5991 context->GetIsolate()->RemoveMessageListeners(
5992 check_custom_rethrowing_message);
5993}
5994
5995
5996static void receive_message(v8::Local<v8::Message> message,
5997 v8::Local<v8::Value> data) {
5998 message->Get();
5999 message_received = true;
6000}
6001
6002
6003TEST(APIThrowMessage)static void TestAPIThrowMessage(); CcTest register_test_APIThrowMessage
(TestAPIThrowMessage, "../test/cctest/test-api.cc", "APIThrowMessage"
, __null, true, true); static void TestAPIThrowMessage()
{
6004 message_received = false;
6005 v8::Isolate* isolate = CcTest::isolate();
6006 v8::HandleScope scope(isolate);
6007 isolate->AddMessageListener(receive_message);
6008 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6009 templ->Set(v8_str("ThrowFromC"),
6010 v8::FunctionTemplate::New(isolate, ThrowFromC));
6011 LocalContext context(0, templ);
6012 CompileRun("ThrowFromC();");
6013 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6013, "Check failed: %s.", "message_received"
); } } while (0)
;
6014 isolate->RemoveMessageListeners(receive_message);
6015}
6016
6017
6018TEST(APIThrowMessageAndVerboseTryCatch)static void TestAPIThrowMessageAndVerboseTryCatch(); CcTest register_test_APIThrowMessageAndVerboseTryCatch
(TestAPIThrowMessageAndVerboseTryCatch, "../test/cctest/test-api.cc"
, "APIThrowMessageAndVerboseTryCatch", __null, true, true); static
void TestAPIThrowMessageAndVerboseTryCatch()
{
6019 message_received = false;
6020 v8::Isolate* isolate = CcTest::isolate();
6021 v8::HandleScope scope(isolate);
6022 isolate->AddMessageListener(receive_message);
6023 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6024 templ->Set(v8_str("ThrowFromC"),
6025 v8::FunctionTemplate::New(isolate, ThrowFromC));
6026 LocalContext context(0, templ);
6027 v8::TryCatch try_catch(isolate);
6028 try_catch.SetVerbose(true);
6029 Local<Value> result = CompileRun("ThrowFromC();");
6030 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6030, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6031 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6031, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
6032 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6032, "Check failed: %s.", "message_received"
); } } while (0)
;
6033 isolate->RemoveMessageListeners(receive_message);
6034}
6035
6036
6037TEST(APIStackOverflowAndVerboseTryCatch)static void TestAPIStackOverflowAndVerboseTryCatch(); CcTest register_test_APIStackOverflowAndVerboseTryCatch
(TestAPIStackOverflowAndVerboseTryCatch, "../test/cctest/test-api.cc"
, "APIStackOverflowAndVerboseTryCatch", __null, true, true); static
void TestAPIStackOverflowAndVerboseTryCatch()
{
6038 message_received = false;
6039 LocalContext context;
6040 v8::HandleScope scope(context->GetIsolate());
6041 context->GetIsolate()->AddMessageListener(receive_message);
6042 v8::TryCatch try_catch(context->GetIsolate());
6043 try_catch.SetVerbose(true);
6044 Local<Value> result = CompileRun("function foo() { foo(); } foo();");
6045 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6045, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6046 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6046, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
6047 CHECK(message_received)do { if ((__builtin_expect(!!(!(message_received)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6047, "Check failed: %s.", "message_received"
); } } while (0)
;
6048 context->GetIsolate()->RemoveMessageListeners(receive_message);
6049}
6050
6051
6052THREADED_TEST(ExternalScriptException)static void TestExternalScriptException(); RegisterThreadedTest
register_ExternalScriptException(TestExternalScriptException
, "ExternalScriptException"); static void TestExternalScriptException
(); CcTest register_test_ExternalScriptException(TestExternalScriptException
, "../test/cctest/test-api.cc", "ExternalScriptException", __null
, true, true); static void TestExternalScriptException()
{
6053 v8::Isolate* isolate = CcTest::isolate();
6054 v8::HandleScope scope(isolate);
6055 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6056 templ->Set(v8_str("ThrowFromC"),
6057 v8::FunctionTemplate::New(isolate, ThrowFromC));
6058 LocalContext context(0, templ);
6059
6060 v8::TryCatch try_catch(isolate);
6061 Local<Value> result = CompileRun("ThrowFromC(); throw 'panama';");
6062 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6062, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
6063 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6063, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6064 String::Utf8Value exception_value(try_catch.Exception());
6065 CHECK_EQ(0, strcmp("konto", *exception_value))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("konto", *exception_value)), "0" " " "==" " " "strcmp(\"konto\", *exception_value)"
)) { V8_Fatal("../test/cctest/test-api.cc", 6065, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6066}
6067
6068
6069void CThrowCountDown(const v8::FunctionCallbackInfo<v8::Value>& args) {
6070 ApiTestFuzzer::Fuzz();
6071 CHECK_EQ(4, args.Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (args
.Length()), "4" " " "==" " " "args.Length()")) { V8_Fatal("../test/cctest/test-api.cc"
, 6071, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6072 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
6073 int count = args[0]->Int32Value(context).FromJust();
6074 int cInterval = args[2]->Int32Value(context).FromJust();
6075 if (count == 0) {
6076 args.GetIsolate()->ThrowException(v8_str("FromC"));
6077 return;
6078 } else {
6079 Local<v8::Object> global = context->Global();
6080 Local<Value> fun =
6081 global->Get(context, v8_str("JSThrowCountDown")).ToLocalChecked();
6082 v8::Local<Value> argv[] = {v8_num(count - 1), args[1], args[2], args[3]};
6083 if (count % cInterval == 0) {
6084 v8::TryCatch try_catch(args.GetIsolate());
6085 Local<Value> result = fun.As<Function>()
6086 ->Call(context, global, 4, argv)
6087 .FromMaybe(Local<Value>());
6088 int expected = args[3]->Int32Value(context).FromJust();
6089 if (try_catch.HasCaught()) {
6090 CHECK_EQ(expected, count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected
), (count), "expected" " " "==" " " "count")) { V8_Fatal("../test/cctest/test-api.cc"
, 6090, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6091 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6091, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
6092 CHECK(!CcTest::i_isolate()->has_scheduled_exception())do { if ((__builtin_expect(!!(!(!CcTest::i_isolate()->has_scheduled_exception
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6092, "Check failed: %s."
, "!CcTest::i_isolate()->has_scheduled_exception()"); } } while
(0)
;
6093 } else {
6094 CHECK_NE(expected, count)do { if (std::string* _msg = ::v8::base::CheckNEImpl( (expected
), (count), "expected" " " "!=" " " "count")) { V8_Fatal("../test/cctest/test-api.cc"
, 6094, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6095 }
6096 args.GetReturnValue().Set(result);
6097 return;
6098 } else {
6099 args.GetReturnValue().Set(fun.As<Function>()
6100 ->Call(context, global, 4, argv)
6101 .FromMaybe(v8::Local<v8::Value>()));
6102 return;
6103 }
6104 }
6105}
6106
6107
6108void JSCheck(const v8::FunctionCallbackInfo<v8::Value>& args) {
6109 ApiTestFuzzer::Fuzz();
6110 CHECK_EQ(3, args.Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (args
.Length()), "3" " " "==" " " "args.Length()")) { V8_Fatal("../test/cctest/test-api.cc"
, 6110, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6111 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
6112 bool equality = args[0]->BooleanValue(context).FromJust();
6113 int count = args[1]->Int32Value(context).FromJust();
6114 int expected = args[2]->Int32Value(context).FromJust();
6115 if (equality) {
6116 CHECK_EQ(count, expected)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (count)
, (expected), "count" " " "==" " " "expected")) { V8_Fatal("../test/cctest/test-api.cc"
, 6116, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6117 } else {
6118 CHECK_NE(count, expected)do { if (std::string* _msg = ::v8::base::CheckNEImpl( (count)
, (expected), "count" " " "!=" " " "expected")) { V8_Fatal("../test/cctest/test-api.cc"
, 6118, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6119 }
6120}
6121
6122
6123THREADED_TEST(EvalInTryFinally)static void TestEvalInTryFinally(); RegisterThreadedTest register_EvalInTryFinally
(TestEvalInTryFinally, "EvalInTryFinally"); static void TestEvalInTryFinally
(); CcTest register_test_EvalInTryFinally(TestEvalInTryFinally
, "../test/cctest/test-api.cc", "EvalInTryFinally", __null, true
, true); static void TestEvalInTryFinally()
{
6124 LocalContext context;
6125 v8::HandleScope scope(context->GetIsolate());
6126 v8::TryCatch try_catch(context->GetIsolate());
6127 CompileRun(
6128 "(function() {"
6129 " try {"
6130 " eval('asldkf (*&^&*^');"
6131 " } finally {"
6132 " return;"
6133 " }"
6134 "})()");
6135 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6135, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6136}
6137
6138
6139// This test works by making a stack of alternating JavaScript and C
6140// activations. These activations set up exception handlers with regular
6141// intervals, one interval for C activations and another for JavaScript
6142// activations. When enough activations have been created an exception is
6143// thrown and we check that the right activation catches the exception and that
6144// no other activations do. The right activation is always the topmost one with
6145// a handler, regardless of whether it is in JavaScript or C.
6146//
6147// The notation used to describe a test case looks like this:
6148//
6149// *JS[4] *C[3] @JS[2] C[1] JS[0]
6150//
6151// Each entry is an activation, either JS or C. The index is the count at that
6152// level. Stars identify activations with exception handlers, the @ identifies
6153// the exception handler that should catch the exception.
6154//
6155// BUG(271): Some of the exception propagation does not work on the
6156// ARM simulator because the simulator separates the C++ stack and the
6157// JS stack. This test therefore fails on the simulator. The test is
6158// not threaded to allow the threading tests to run on the simulator.
6159TEST(ExceptionOrder)static void TestExceptionOrder(); CcTest register_test_ExceptionOrder
(TestExceptionOrder, "../test/cctest/test-api.cc", "ExceptionOrder"
, __null, true, true); static void TestExceptionOrder()
{
6160 v8::Isolate* isolate = CcTest::isolate();
6161 v8::HandleScope scope(isolate);
6162 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6163 templ->Set(v8_str("check"), v8::FunctionTemplate::New(isolate, JSCheck));
6164 templ->Set(v8_str("CThrowCountDown"),
6165 v8::FunctionTemplate::New(isolate, CThrowCountDown));
6166 LocalContext context(0, templ);
6167 CompileRun(
6168 "function JSThrowCountDown(count, jsInterval, cInterval, expected) {"
6169 " if (count == 0) throw 'FromJS';"
6170 " if (count % jsInterval == 0) {"
6171 " try {"
6172 " var value = CThrowCountDown(count - 1,"
6173 " jsInterval,"
6174 " cInterval,"
6175 " expected);"
6176 " check(false, count, expected);"
6177 " return value;"
6178 " } catch (e) {"
6179 " check(true, count, expected);"
6180 " }"
6181 " } else {"
6182 " return CThrowCountDown(count - 1, jsInterval, cInterval, expected);"
6183 " }"
6184 "}");
6185 Local<Function> fun = Local<Function>::Cast(
6186 context->Global()
6187 ->Get(context.local(), v8_str("JSThrowCountDown"))
6188 .ToLocalChecked());
6189
6190 const int argc = 4;
6191 // count jsInterval cInterval expected
6192
6193 // *JS[4] *C[3] @JS[2] C[1] JS[0]
6194 v8::Local<Value> a0[argc] = {v8_num(4), v8_num(2), v8_num(3), v8_num(2)};
6195 fun->Call(context.local(), fun, argc, a0).ToLocalChecked();
6196
6197 // JS[5] *C[4] JS[3] @C[2] JS[1] C[0]
6198 v8::Local<Value> a1[argc] = {v8_num(5), v8_num(6), v8_num(1), v8_num(2)};
6199 fun->Call(context.local(), fun, argc, a1).ToLocalChecked();
6200
6201 // JS[6] @C[5] JS[4] C[3] JS[2] C[1] JS[0]
6202 v8::Local<Value> a2[argc] = {v8_num(6), v8_num(7), v8_num(5), v8_num(5)};
6203 fun->Call(context.local(), fun, argc, a2).ToLocalChecked();
6204
6205 // @JS[6] C[5] JS[4] C[3] JS[2] C[1] JS[0]
6206 v8::Local<Value> a3[argc] = {v8_num(6), v8_num(6), v8_num(7), v8_num(6)};
6207 fun->Call(context.local(), fun, argc, a3).ToLocalChecked();
6208
6209 // JS[6] *C[5] @JS[4] C[3] JS[2] C[1] JS[0]
6210 v8::Local<Value> a4[argc] = {v8_num(6), v8_num(4), v8_num(5), v8_num(4)};
6211 fun->Call(context.local(), fun, argc, a4).ToLocalChecked();
6212
6213 // JS[6] C[5] *JS[4] @C[3] JS[2] C[1] JS[0]
6214 v8::Local<Value> a5[argc] = {v8_num(6), v8_num(4), v8_num(3), v8_num(3)};
6215 fun->Call(context.local(), fun, argc, a5).ToLocalChecked();
6216}
6217
6218
6219void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) {
6220 ApiTestFuzzer::Fuzz();
6221 CHECK_EQ(1, args.Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (args
.Length()), "1" " " "==" " " "args.Length()")) { V8_Fatal("../test/cctest/test-api.cc"
, 6221, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6222 args.GetIsolate()->ThrowException(args[0]);
6223}
6224
6225
6226THREADED_TEST(ThrowValues)static void TestThrowValues(); RegisterThreadedTest register_ThrowValues
(TestThrowValues, "ThrowValues"); static void TestThrowValues
(); CcTest register_test_ThrowValues(TestThrowValues, "../test/cctest/test-api.cc"
, "ThrowValues", __null, true, true); static void TestThrowValues
()
{
6227 v8::Isolate* isolate = CcTest::isolate();
6228 v8::HandleScope scope(isolate);
6229 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6230 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(isolate, ThrowValue));
6231 LocalContext context(0, templ);
6232 v8::Local<v8::Array> result = v8::Local<v8::Array>::Cast(
6233 CompileRun("function Run(obj) {"
6234 " try {"
6235 " Throw(obj);"
6236 " } catch (e) {"
6237 " return e;"
6238 " }"
6239 " return 'no exception';"
6240 "}"
6241 "[Run('str'), Run(1), Run(0), Run(null), Run(void 0)];"));
6242 CHECK_EQ(5u, result->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5u), (
result->Length()), "5u" " " "==" " " "result->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6242, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6243 CHECK(result->Get(context.local(), v8::Integer::New(isolate, 0))do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->IsString
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6245, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->IsString()"
); } } while (0)
6244 .ToLocalChecked()do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->IsString
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6245, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->IsString()"
); } } while (0)
6245 ->IsString())do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->IsString
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6245, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 0)) .ToLocalChecked() ->IsString()"
); } } while (0)
;
6246 CHECK(result->Get(context.local(), v8::Integer::New(isolate, 1))do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->IsNumber
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6248, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->IsNumber()"
); } } while (0)
6247 .ToLocalChecked()do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->IsNumber
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6248, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->IsNumber()"
); } } while (0)
6248 ->IsNumber())do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->IsNumber
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6248, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->IsNumber()"
); } } while (0)
;
6249 CHECK_EQ(1, result->Get(context.local(), v8::Integer::New(isolate, 1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (result
->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "1" " " "=="
" " "result->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6252, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6250 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (result
->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "1" " " "=="
" " "result->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6252, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6251 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (result
->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "1" " " "=="
" " "result->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6252, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6252 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (result
->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "1" " " "=="
" " "result->Get(context.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6252, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6253 CHECK(result->Get(context.local(), v8::Integer::New(isolate, 2))do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->IsNumber
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6255, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->IsNumber()"
); } } while (0)
6254 .ToLocalChecked()do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->IsNumber
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6255, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->IsNumber()"
); } } while (0)
6255 ->IsNumber())do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->IsNumber
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6255, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->IsNumber()"
); } } while (0)
;
6256 CHECK_EQ(0, result->Get(context.local(), v8::Integer::New(isolate, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (result
->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "0" " " "=="
" " "result->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6259, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6257 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (result
->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "0" " " "=="
" " "result->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6259, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6258 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (result
->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "0" " " "=="
" " "result->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6259, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6259 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (result
->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked
() ->Int32Value(context.local()) .FromJust()), "0" " " "=="
" " "result->Get(context.local(), v8::Integer::New(isolate, 2)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6259, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6260 CHECK(result->Get(context.local(), v8::Integer::New(isolate, 3))do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->IsNull
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6262, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->IsNull()"
); } } while (0)
6261 .ToLocalChecked()do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->IsNull
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6262, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->IsNull()"
); } } while (0)
6262 ->IsNull())do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->IsNull
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6262, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->IsNull()"
); } } while (0)
;
6263 CHECK(result->Get(context.local(), v8::Integer::New(isolate, 4))do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 4)) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6265, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 4)) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
6264 .ToLocalChecked()do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 4)) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6265, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 4)) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
6265 ->IsUndefined())do { if ((__builtin_expect(!!(!(result->Get(context.local(
), v8::Integer::New(isolate, 4)) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6265, "Check failed: %s."
, "result->Get(context.local(), v8::Integer::New(isolate, 4)) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
6266}
6267
6268
6269THREADED_TEST(CatchZero)static void TestCatchZero(); RegisterThreadedTest register_CatchZero
(TestCatchZero, "CatchZero"); static void TestCatchZero(); CcTest
register_test_CatchZero(TestCatchZero, "../test/cctest/test-api.cc"
, "CatchZero", __null, true, true); static void TestCatchZero
()
{
6270 LocalContext context;
6271 v8::HandleScope scope(context->GetIsolate());
6272 v8::TryCatch try_catch(context->GetIsolate());
6273 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6273, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6274 CompileRun("throw 10");
6275 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6275, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6276 CHECK_EQ(10, try_catch.Exception()->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10), (
try_catch.Exception()->Int32Value(context.local()).FromJust
()), "10" " " "==" " " "try_catch.Exception()->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6276, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6277 try_catch.Reset();
6278 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6278, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6279 CompileRun("throw 0");
6280 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6280, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6281 CHECK_EQ(0, try_catch.Exception()->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (try_catch
.Exception()->Int32Value(context.local()).FromJust()), "0"
" " "==" " " "try_catch.Exception()->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6281, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6282}
6283
6284
6285THREADED_TEST(CatchExceptionFromWith)static void TestCatchExceptionFromWith(); RegisterThreadedTest
register_CatchExceptionFromWith(TestCatchExceptionFromWith, "CatchExceptionFromWith"
); static void TestCatchExceptionFromWith(); CcTest register_test_CatchExceptionFromWith
(TestCatchExceptionFromWith, "../test/cctest/test-api.cc", "CatchExceptionFromWith"
, __null, true, true); static void TestCatchExceptionFromWith
()
{
6286 LocalContext context;
6287 v8::HandleScope scope(context->GetIsolate());
6288 v8::TryCatch try_catch(context->GetIsolate());
6289 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6289, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6290 CompileRun("var o = {}; with (o) { throw 42; }");
6291 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6291, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6292}
6293
6294
6295THREADED_TEST(TryCatchAndFinallyHidingException)static void TestTryCatchAndFinallyHidingException(); RegisterThreadedTest
register_TryCatchAndFinallyHidingException(TestTryCatchAndFinallyHidingException
, "TryCatchAndFinallyHidingException"); static void TestTryCatchAndFinallyHidingException
(); CcTest register_test_TryCatchAndFinallyHidingException(TestTryCatchAndFinallyHidingException
, "../test/cctest/test-api.cc", "TryCatchAndFinallyHidingException"
, __null, true, true); static void TestTryCatchAndFinallyHidingException
()
{
6296 LocalContext context;
6297 v8::HandleScope scope(context->GetIsolate());
6298 v8::TryCatch try_catch(context->GetIsolate());
6299 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6299, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6300 CompileRun("function f(k) { try { this[k]; } finally { return 0; } };");
6301 CompileRun("f({toString: function() { throw 42; }});");
6302 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6302, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6303}
6304
6305
6306void WithTryCatch(const v8::FunctionCallbackInfo<v8::Value>& args) {
6307 v8::TryCatch try_catch(args.GetIsolate());
6308}
6309
6310
6311THREADED_TEST(TryCatchAndFinally)static void TestTryCatchAndFinally(); RegisterThreadedTest register_TryCatchAndFinally
(TestTryCatchAndFinally, "TryCatchAndFinally"); static void TestTryCatchAndFinally
(); CcTest register_test_TryCatchAndFinally(TestTryCatchAndFinally
, "../test/cctest/test-api.cc", "TryCatchAndFinally", __null,
true, true); static void TestTryCatchAndFinally()
{
6312 LocalContext context;
6313 v8::Isolate* isolate = context->GetIsolate();
6314 v8::HandleScope scope(isolate);
6315 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("native_with_try_catch"), v8::FunctionTemplate
::New(isolate, WithTryCatch) ->GetFunction(context.local()
) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6320, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"native_with_try_catch\"), v8::FunctionTemplate::New(isolate, WithTryCatch) ->GetFunction(context.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
6316 ->Set(context.local(), v8_str("native_with_try_catch"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("native_with_try_catch"), v8::FunctionTemplate
::New(isolate, WithTryCatch) ->GetFunction(context.local()
) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6320, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"native_with_try_catch\"), v8::FunctionTemplate::New(isolate, WithTryCatch) ->GetFunction(context.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
6317 v8::FunctionTemplate::New(isolate, WithTryCatch)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("native_with_try_catch"), v8::FunctionTemplate
::New(isolate, WithTryCatch) ->GetFunction(context.local()
) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6320, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"native_with_try_catch\"), v8::FunctionTemplate::New(isolate, WithTryCatch) ->GetFunction(context.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
6318 ->GetFunction(context.local())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("native_with_try_catch"), v8::FunctionTemplate
::New(isolate, WithTryCatch) ->GetFunction(context.local()
) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6320, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"native_with_try_catch\"), v8::FunctionTemplate::New(isolate, WithTryCatch) ->GetFunction(context.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
6319 .ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("native_with_try_catch"), v8::FunctionTemplate
::New(isolate, WithTryCatch) ->GetFunction(context.local()
) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6320, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"native_with_try_catch\"), v8::FunctionTemplate::New(isolate, WithTryCatch) ->GetFunction(context.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
6320 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("native_with_try_catch"), v8::FunctionTemplate
::New(isolate, WithTryCatch) ->GetFunction(context.local()
) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6320, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"native_with_try_catch\"), v8::FunctionTemplate::New(isolate, WithTryCatch) ->GetFunction(context.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
6321 v8::TryCatch try_catch(isolate);
6322 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6322, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6323 CompileRun(
6324 "try {\n"
6325 " throw new Error('a');\n"
6326 "} finally {\n"
6327 " native_with_try_catch();\n"
6328 "}\n");
6329 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6329, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6330}
6331
6332
6333static void TryCatchNested1Helper(int depth) {
6334 if (depth > 0) {
6335 v8::TryCatch try_catch(CcTest::isolate());
6336 try_catch.SetVerbose(true);
6337 TryCatchNested1Helper(depth - 1);
6338 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6338, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6339 try_catch.ReThrow();
6340 } else {
6341 CcTest::isolate()->ThrowException(v8_str("E1"));
6342 }
6343}
6344
6345
6346static void TryCatchNested2Helper(int depth) {
6347 if (depth > 0) {
6348 v8::TryCatch try_catch(CcTest::isolate());
6349 try_catch.SetVerbose(true);
6350 TryCatchNested2Helper(depth - 1);
6351 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6351, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6352 try_catch.ReThrow();
6353 } else {
6354 CompileRun("throw 'E2';");
6355 }
6356}
6357
6358
6359TEST(TryCatchNested)static void TestTryCatchNested(); CcTest register_test_TryCatchNested
(TestTryCatchNested, "../test/cctest/test-api.cc", "TryCatchNested"
, __null, true, true); static void TestTryCatchNested()
{
6360 v8::V8::Initialize();
6361 LocalContext context;
6362 v8::HandleScope scope(context->GetIsolate());
6363
6364 {
6365 // Test nested try-catch with a native throw in the end.
6366 v8::TryCatch try_catch(context->GetIsolate());
6367 TryCatchNested1Helper(5);
6368 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6368, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6369 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*v8::String::Utf8Value(try_catch.Exception()), "E1")), "0" " "
"==" " " "strcmp(*v8::String::Utf8Value(try_catch.Exception()), \"E1\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6369, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6370 }
6371
6372 {
6373 // Test nested try-catch with a JavaScript throw in the end.
6374 v8::TryCatch try_catch(context->GetIsolate());
6375 TryCatchNested2Helper(5);
6376 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6376, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6377 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(try_catch.Exception()), "E2"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*v8::String::Utf8Value(try_catch.Exception()), "E2")), "0" " "
"==" " " "strcmp(*v8::String::Utf8Value(try_catch.Exception()), \"E2\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6377, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6378 }
6379}
6380
6381
6382void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) {
6383 CHECK(try_catch->HasCaught())do { if ((__builtin_expect(!!(!(try_catch->HasCaught())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 6383, "Check failed: %s."
, "try_catch->HasCaught()"); } } while (0)
;
6384 Local<Message> message = try_catch->Message();
6385 Local<Value> resource = message->GetScriptOrigin().ResourceName();
6386 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*v8::String::Utf8Value(resource), "inner")), "0" " " "==" " "
"strcmp(*v8::String::Utf8Value(resource), \"inner\")")) { V8_Fatal
("../test/cctest/test-api.cc", 6386, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
6387 CHECK_EQ(0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*v8::String::Utf8Value(message->Get()), "Uncaught Error: a"
)), "0" " " "==" " " "strcmp(*v8::String::Utf8Value(message->Get()), \"Uncaught Error: a\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6388, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6388 strcmp(*v8::String::Utf8Value(message->Get()), "Uncaught Error: a"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*v8::String::Utf8Value(message->Get()), "Uncaught Error: a"
)), "0" " " "==" " " "strcmp(*v8::String::Utf8Value(message->Get()), \"Uncaught Error: a\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6388, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6389 CHECK_EQ(1, message->GetLineNumber(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (message
->GetLineNumber(CcTest::isolate()->GetCurrentContext())
.FromJust()), "1" " " "==" " " "message->GetLineNumber(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6390, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6390 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (message
->GetLineNumber(CcTest::isolate()->GetCurrentContext())
.FromJust()), "1" " " "==" " " "message->GetLineNumber(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6390, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6391 CHECK_EQ(0, message->GetStartColumn(CcTest::isolate()->GetCurrentContext())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (message
->GetStartColumn(CcTest::isolate()->GetCurrentContext()
) .FromJust()), "0" " " "==" " " "message->GetStartColumn(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6392, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6392 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (message
->GetStartColumn(CcTest::isolate()->GetCurrentContext()
) .FromJust()), "0" " " "==" " " "message->GetStartColumn(CcTest::isolate()->GetCurrentContext()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6392, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6393}
6394
6395
6396void TryCatchMixedNestingHelper(
6397 const v8::FunctionCallbackInfo<v8::Value>& args) {
6398 ApiTestFuzzer::Fuzz();
6399 v8::TryCatch try_catch(args.GetIsolate());
6400 CompileRunWithOrigin("throw new Error('a');\n", "inner", 0, 0);
6401 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6401, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6402 TryCatchMixedNestingCheck(&try_catch);
6403 try_catch.ReThrow();
6404}
6405
6406
6407// This test ensures that an outer TryCatch in the following situation:
6408// C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError
6409// does not clobber the Message object generated for the inner TryCatch.
6410// This exercises the ability of TryCatch.ReThrow() to restore the
6411// inner pending Message before throwing the exception again.
6412TEST(TryCatchMixedNesting)static void TestTryCatchMixedNesting(); CcTest register_test_TryCatchMixedNesting
(TestTryCatchMixedNesting, "../test/cctest/test-api.cc", "TryCatchMixedNesting"
, __null, true, true); static void TestTryCatchMixedNesting()
{
6413 v8::Isolate* isolate = CcTest::isolate();
6414 v8::HandleScope scope(isolate);
6415 v8::V8::Initialize();
6416 v8::TryCatch try_catch(isolate);
6417 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6418 templ->Set(v8_str("TryCatchMixedNestingHelper"),
6419 v8::FunctionTemplate::New(isolate, TryCatchMixedNestingHelper));
6420 LocalContext context(0, templ);
6421 CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1);
6422 TryCatchMixedNestingCheck(&try_catch);
6423}
6424
6425
6426void TryCatchNativeHelper(const v8::FunctionCallbackInfo<v8::Value>& args) {
6427 ApiTestFuzzer::Fuzz();
6428 v8::TryCatch try_catch(args.GetIsolate());
6429 args.GetIsolate()->ThrowException(v8_str("boom"));
6430 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6430, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6431}
6432
6433
6434TEST(TryCatchNative)static void TestTryCatchNative(); CcTest register_test_TryCatchNative
(TestTryCatchNative, "../test/cctest/test-api.cc", "TryCatchNative"
, __null, true, true); static void TestTryCatchNative()
{
6435 v8::Isolate* isolate = CcTest::isolate();
6436 v8::HandleScope scope(isolate);
6437 v8::V8::Initialize();
6438 v8::TryCatch try_catch(isolate);
6439 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6440 templ->Set(v8_str("TryCatchNativeHelper"),
6441 v8::FunctionTemplate::New(isolate, TryCatchNativeHelper));
6442 LocalContext context(0, templ);
6443 CompileRun("TryCatchNativeHelper();");
6444 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6444, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6445}
6446
6447
6448void TryCatchNativeResetHelper(
6449 const v8::FunctionCallbackInfo<v8::Value>& args) {
6450 ApiTestFuzzer::Fuzz();
6451 v8::TryCatch try_catch(args.GetIsolate());
6452 args.GetIsolate()->ThrowException(v8_str("boom"));
6453 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6453, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6454 try_catch.Reset();
6455 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6455, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6456}
6457
6458
6459TEST(TryCatchNativeReset)static void TestTryCatchNativeReset(); CcTest register_test_TryCatchNativeReset
(TestTryCatchNativeReset, "../test/cctest/test-api.cc", "TryCatchNativeReset"
, __null, true, true); static void TestTryCatchNativeReset()
{
6460 v8::Isolate* isolate = CcTest::isolate();
6461 v8::HandleScope scope(isolate);
6462 v8::V8::Initialize();
6463 v8::TryCatch try_catch(isolate);
6464 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6465 templ->Set(v8_str("TryCatchNativeResetHelper"),
6466 v8::FunctionTemplate::New(isolate, TryCatchNativeResetHelper));
6467 LocalContext context(0, templ);
6468 CompileRun("TryCatchNativeResetHelper();");
6469 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6469, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
6470}
6471
6472
6473THREADED_TEST(Equality)static void TestEquality(); RegisterThreadedTest register_Equality
(TestEquality, "Equality"); static void TestEquality(); CcTest
register_test_Equality(TestEquality, "../test/cctest/test-api.cc"
, "Equality", __null, true, true); static void TestEquality()
{
6474 LocalContext context;
6475 v8::Isolate* isolate = context->GetIsolate();
6476 v8::HandleScope scope(context->GetIsolate());
6477 // Check that equality works at all before relying on CHECK_EQ
6478 CHECK(v8_str("a")->Equals(context.local(), v8_str("a")).FromJust())do { if ((__builtin_expect(!!(!(v8_str("a")->Equals(context
.local(), v8_str("a")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6478, "Check failed: %s.", "v8_str(\"a\")->Equals(context.local(), v8_str(\"a\")).FromJust()"
); } } while (0)
;
6479 CHECK(!v8_str("a")->Equals(context.local(), v8_str("b")).FromJust())do { if ((__builtin_expect(!!(!(!v8_str("a")->Equals(context
.local(), v8_str("b")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6479, "Check failed: %s.", "!v8_str(\"a\")->Equals(context.local(), v8_str(\"b\")).FromJust()"
); } } while (0)
;
6480
6481 CHECK(v8_str("a")->Equals(context.local(), v8_str("a")).FromJust())do { if ((__builtin_expect(!!(!(v8_str("a")->Equals(context
.local(), v8_str("a")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6481, "Check failed: %s.", "v8_str(\"a\")->Equals(context.local(), v8_str(\"a\")).FromJust()"
); } } while (0)
;
6482 CHECK(!v8_str("a")->Equals(context.local(), v8_str("b")).FromJust())do { if ((__builtin_expect(!!(!(!v8_str("a")->Equals(context
.local(), v8_str("b")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6482, "Check failed: %s.", "!v8_str(\"a\")->Equals(context.local(), v8_str(\"b\")).FromJust()"
); } } while (0)
;
6483 CHECK(v8_num(1)->Equals(context.local(), v8_num(1)).FromJust())do { if ((__builtin_expect(!!(!(v8_num(1)->Equals(context.
local(), v8_num(1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6483, "Check failed: %s.", "v8_num(1)->Equals(context.local(), v8_num(1)).FromJust()"
); } } while (0)
;
6484 CHECK(v8_num(1.00)->Equals(context.local(), v8_num(1)).FromJust())do { if ((__builtin_expect(!!(!(v8_num(1.00)->Equals(context
.local(), v8_num(1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6484, "Check failed: %s.", "v8_num(1.00)->Equals(context.local(), v8_num(1)).FromJust()"
); } } while (0)
;
6485 CHECK(!v8_num(1)->Equals(context.local(), v8_num(2)).FromJust())do { if ((__builtin_expect(!!(!(!v8_num(1)->Equals(context
.local(), v8_num(2)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6485, "Check failed: %s.", "!v8_num(1)->Equals(context.local(), v8_num(2)).FromJust()"
); } } while (0)
;
6486
6487 // Assume String is not internalized.
6488 CHECK(v8_str("a")->StrictEquals(v8_str("a")))do { if ((__builtin_expect(!!(!(v8_str("a")->StrictEquals(
v8_str("a")))), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6488, "Check failed: %s.", "v8_str(\"a\")->StrictEquals(v8_str(\"a\"))"
); } } while (0)
;
6489 CHECK(!v8_str("a")->StrictEquals(v8_str("b")))do { if ((__builtin_expect(!!(!(!v8_str("a")->StrictEquals
(v8_str("b")))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6489, "Check failed: %s.", "!v8_str(\"a\")->StrictEquals(v8_str(\"b\"))"
); } } while (0)
;
6490 CHECK(!v8_str("5")->StrictEquals(v8_num(5)))do { if ((__builtin_expect(!!(!(!v8_str("5")->StrictEquals
(v8_num(5)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6490
, "Check failed: %s.", "!v8_str(\"5\")->StrictEquals(v8_num(5))"
); } } while (0)
;
6491 CHECK(v8_num(1)->StrictEquals(v8_num(1)))do { if ((__builtin_expect(!!(!(v8_num(1)->StrictEquals(v8_num
(1)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6491, "Check failed: %s."
, "v8_num(1)->StrictEquals(v8_num(1))"); } } while (0)
;
6492 CHECK(!v8_num(1)->StrictEquals(v8_num(2)))do { if ((__builtin_expect(!!(!(!v8_num(1)->StrictEquals(v8_num
(2)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6492, "Check failed: %s."
, "!v8_num(1)->StrictEquals(v8_num(2))"); } } while (0)
;
6493 CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0)))do { if ((__builtin_expect(!!(!(v8_num(0.0)->StrictEquals(
v8_num(-0.0)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6493, "Check failed: %s.", "v8_num(0.0)->StrictEquals(v8_num(-0.0))"
); } } while (0)
;
6494 Local<Value> not_a_number = v8_num(std::numeric_limits<double>::quiet_NaN());
6495 CHECK(!not_a_number->StrictEquals(not_a_number))do { if ((__builtin_expect(!!(!(!not_a_number->StrictEquals
(not_a_number))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6495, "Check failed: %s.", "!not_a_number->StrictEquals(not_a_number)"
); } } while (0)
;
6496 CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate)))do { if ((__builtin_expect(!!(!(v8::False(isolate)->StrictEquals
(v8::False(isolate)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6496, "Check failed: %s.", "v8::False(isolate)->StrictEquals(v8::False(isolate))"
); } } while (0)
;
6497 CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate)))do { if ((__builtin_expect(!!(!(!v8::False(isolate)->StrictEquals
(v8::Undefined(isolate)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6497, "Check failed: %s.", "!v8::False(isolate)->StrictEquals(v8::Undefined(isolate))"
); } } while (0)
;
6498
6499 v8::Local<v8::Object> obj = v8::Object::New(isolate);
6500 v8::Persistent<v8::Object> alias(isolate, obj);
6501 CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj))do { if ((__builtin_expect(!!(!(v8::Local<v8::Object>::
New(isolate, alias)->StrictEquals(obj))), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 6501, "Check failed: %s.", "v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)"
); } } while (0)
;
6502 alias.Reset();
6503
6504 CHECK(v8_str("a")->SameValue(v8_str("a")))do { if ((__builtin_expect(!!(!(v8_str("a")->SameValue(v8_str
("a")))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6504,
"Check failed: %s.", "v8_str(\"a\")->SameValue(v8_str(\"a\"))"
); } } while (0)
;
6505 CHECK(!v8_str("a")->SameValue(v8_str("b")))do { if ((__builtin_expect(!!(!(!v8_str("a")->SameValue(v8_str
("b")))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6505,
"Check failed: %s.", "!v8_str(\"a\")->SameValue(v8_str(\"b\"))"
); } } while (0)
;
6506 CHECK(!v8_str("5")->SameValue(v8_num(5)))do { if ((__builtin_expect(!!(!(!v8_str("5")->SameValue(v8_num
(5)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6506, "Check failed: %s."
, "!v8_str(\"5\")->SameValue(v8_num(5))"); } } while (0)
;
6507 CHECK(v8_num(1)->SameValue(v8_num(1)))do { if ((__builtin_expect(!!(!(v8_num(1)->SameValue(v8_num
(1)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6507, "Check failed: %s."
, "v8_num(1)->SameValue(v8_num(1))"); } } while (0)
;
6508 CHECK(!v8_num(1)->SameValue(v8_num(2)))do { if ((__builtin_expect(!!(!(!v8_num(1)->SameValue(v8_num
(2)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6508, "Check failed: %s."
, "!v8_num(1)->SameValue(v8_num(2))"); } } while (0)
;
6509 CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0)))do { if ((__builtin_expect(!!(!(!v8_num(0.0)->SameValue(v8_num
(-0.0)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6509
, "Check failed: %s.", "!v8_num(0.0)->SameValue(v8_num(-0.0))"
); } } while (0)
;
6510 CHECK(not_a_number->SameValue(not_a_number))do { if ((__builtin_expect(!!(!(not_a_number->SameValue(not_a_number
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6510, "Check failed: %s."
, "not_a_number->SameValue(not_a_number)"); } } while (0)
;
6511 CHECK(v8::False(isolate)->SameValue(v8::False(isolate)))do { if ((__builtin_expect(!!(!(v8::False(isolate)->SameValue
(v8::False(isolate)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6511, "Check failed: %s.", "v8::False(isolate)->SameValue(v8::False(isolate))"
); } } while (0)
;
6512 CHECK(!v8::False(isolate)->SameValue(v8::Undefined(isolate)))do { if ((__builtin_expect(!!(!(!v8::False(isolate)->SameValue
(v8::Undefined(isolate)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6512, "Check failed: %s.", "!v8::False(isolate)->SameValue(v8::Undefined(isolate))"
); } } while (0)
;
6513}
6514
6515
6516THREADED_TEST(MultiRun)static void TestMultiRun(); RegisterThreadedTest register_MultiRun
(TestMultiRun, "MultiRun"); static void TestMultiRun(); CcTest
register_test_MultiRun(TestMultiRun, "../test/cctest/test-api.cc"
, "MultiRun", __null, true, true); static void TestMultiRun()
{
6517 LocalContext context;
6518 v8::HandleScope scope(context->GetIsolate());
6519 Local<Script> script = v8_compile("x");
6520 for (int i = 0; i < 10; i++) {
6521 script->Run(context.local()).IsEmpty();
6522 }
6523}
6524
6525
6526static void GetXValue(Local<Name> name,
6527 const v8::PropertyCallbackInfo<v8::Value>& info) {
6528 ApiTestFuzzer::Fuzz();
6529 CHECK(info.Data()do { if ((__builtin_expect(!!(!(info.Data() ->Equals(CcTest
::isolate()->GetCurrentContext(), v8_str("donut")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6531, "Check failed: %s."
, "info.Data() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(\"donut\")) .FromJust()"
); } } while (0)
6530 ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str("donut"))do { if ((__builtin_expect(!!(!(info.Data() ->Equals(CcTest
::isolate()->GetCurrentContext(), v8_str("donut")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6531, "Check failed: %s."
, "info.Data() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(\"donut\")) .FromJust()"
); } } while (0)
6531 .FromJust())do { if ((__builtin_expect(!!(!(info.Data() ->Equals(CcTest
::isolate()->GetCurrentContext(), v8_str("donut")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6531, "Check failed: %s."
, "info.Data() ->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(\"donut\")) .FromJust()"
); } } while (0)
;
6532 CHECK(name->Equals(CcTest::isolate()->GetCurrentContext(), v8_str("x"))do { if ((__builtin_expect(!!(!(name->Equals(CcTest::isolate
()->GetCurrentContext(), v8_str("x")) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 6533, "Check failed: %s."
, "name->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(\"x\")) .FromJust()"
); } } while (0)
6533 .FromJust())do { if ((__builtin_expect(!!(!(name->Equals(CcTest::isolate
()->GetCurrentContext(), v8_str("x")) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 6533, "Check failed: %s."
, "name->Equals(CcTest::isolate()->GetCurrentContext(), v8_str(\"x\")) .FromJust()"
); } } while (0)
;
6534 info.GetReturnValue().Set(name);
6535}
6536
6537
6538THREADED_TEST(SimplePropertyRead)static void TestSimplePropertyRead(); RegisterThreadedTest register_SimplePropertyRead
(TestSimplePropertyRead, "SimplePropertyRead"); static void TestSimplePropertyRead
(); CcTest register_test_SimplePropertyRead(TestSimplePropertyRead
, "../test/cctest/test-api.cc", "SimplePropertyRead", __null,
true, true); static void TestSimplePropertyRead()
{
6539 LocalContext context;
6540 v8::Isolate* isolate = context->GetIsolate();
6541 v8::HandleScope scope(isolate);
6542 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6543 templ->SetAccessor(v8_str("x"), GetXValue, NULL__null, v8_str("donut"));
6544 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6547, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6545 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6547, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6546 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6547, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6547 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6547, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6548 Local<Script> script = v8_compile("obj.x");
6549 for (int i = 0; i < 10; i++) {
6550 Local<Value> result = script->Run(context.local()).ToLocalChecked();
6551 CHECK(result->Equals(context.local(), v8_str("x")).FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context.local
(), v8_str("x")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6551, "Check failed: %s.", "result->Equals(context.local(), v8_str(\"x\")).FromJust()"
); } } while (0)
;
6552 }
6553}
6554
6555
6556THREADED_TEST(DefinePropertyOnAPIAccessor)static void TestDefinePropertyOnAPIAccessor(); RegisterThreadedTest
register_DefinePropertyOnAPIAccessor(TestDefinePropertyOnAPIAccessor
, "DefinePropertyOnAPIAccessor"); static void TestDefinePropertyOnAPIAccessor
(); CcTest register_test_DefinePropertyOnAPIAccessor(TestDefinePropertyOnAPIAccessor
, "../test/cctest/test-api.cc", "DefinePropertyOnAPIAccessor"
, __null, true, true); static void TestDefinePropertyOnAPIAccessor
()
{
6557 LocalContext context;
6558 v8::Isolate* isolate = context->GetIsolate();
6559 v8::HandleScope scope(isolate);
6560 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6561 templ->SetAccessor(v8_str("x"), GetXValue, NULL__null, v8_str("donut"));
6562 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6565, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6563 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6565, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6564 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6565, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6565 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6565, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6566
6567 // Uses getOwnPropertyDescriptor to check the configurable status
6568 Local<Script> script_desc = v8_compile(
6569 "var prop = Object.getOwnPropertyDescriptor( "
6570 "obj, 'x');"
6571 "prop.configurable;");
6572 Local<Value> result = script_desc->Run(context.local()).ToLocalChecked();
6573 CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result
->BooleanValue(context.local()).FromJust()), (true), "result->BooleanValue(context.local()).FromJust()"
" " "==" " " "true")) { V8_Fatal("../test/cctest/test-api.cc"
, 6573, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6574
6575 // Redefine get - but still configurable
6576 Local<Script> script_define = v8_compile(
6577 "var desc = { get: function(){return 42; },"
6578 " configurable: true };"
6579 "Object.defineProperty(obj, 'x', desc);"
6580 "obj.x");
6581 result = script_define->Run(context.local()).ToLocalChecked();
6582 CHECK(result->Equals(context.local(), v8_num(42)).FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context.local
(), v8_num(42)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6582, "Check failed: %s.", "result->Equals(context.local(), v8_num(42)).FromJust()"
); } } while (0)
;
6583
6584 // Check that the accessor is still configurable
6585 result = script_desc->Run(context.local()).ToLocalChecked();
6586 CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result
->BooleanValue(context.local()).FromJust()), (true), "result->BooleanValue(context.local()).FromJust()"
" " "==" " " "true")) { V8_Fatal("../test/cctest/test-api.cc"
, 6586, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6587
6588 // Redefine to a non-configurable
6589 script_define = v8_compile(
6590 "var desc = { get: function(){return 43; },"
6591 " configurable: false };"
6592 "Object.defineProperty(obj, 'x', desc);"
6593 "obj.x");
6594 result = script_define->Run(context.local()).ToLocalChecked();
6595 CHECK(result->Equals(context.local(), v8_num(43)).FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context.local
(), v8_num(43)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6595, "Check failed: %s.", "result->Equals(context.local(), v8_num(43)).FromJust()"
); } } while (0)
;
6596 result = script_desc->Run(context.local()).ToLocalChecked();
6597 CHECK_EQ(result->BooleanValue(context.local()).FromJust(), false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result
->BooleanValue(context.local()).FromJust()), (false), "result->BooleanValue(context.local()).FromJust()"
" " "==" " " "false")) { V8_Fatal("../test/cctest/test-api.cc"
, 6597, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6598
6599 // Make sure that it is not possible to redefine again
6600 v8::TryCatch try_catch(isolate);
6601 CHECK(script_define->Run(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script_define->Run(context
.local()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6601, "Check failed: %s.", "script_define->Run(context.local()).IsEmpty()"
); } } while (0)
;
6602 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6602, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6603 String::Utf8Value exception_value(try_catch.Exception());
6604 CHECK_EQ(0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "TypeError: Cannot redefine property: x"))
, "0" " " "==" " " "strcmp(*exception_value, \"TypeError: Cannot redefine property: x\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6605, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6605 strcmp(*exception_value, "TypeError: Cannot redefine property: x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "TypeError: Cannot redefine property: x"))
, "0" " " "==" " " "strcmp(*exception_value, \"TypeError: Cannot redefine property: x\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6605, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6606}
6607
6608
6609THREADED_TEST(DefinePropertyOnDefineGetterSetter)static void TestDefinePropertyOnDefineGetterSetter(); RegisterThreadedTest
register_DefinePropertyOnDefineGetterSetter(TestDefinePropertyOnDefineGetterSetter
, "DefinePropertyOnDefineGetterSetter"); static void TestDefinePropertyOnDefineGetterSetter
(); CcTest register_test_DefinePropertyOnDefineGetterSetter(TestDefinePropertyOnDefineGetterSetter
, "../test/cctest/test-api.cc", "DefinePropertyOnDefineGetterSetter"
, __null, true, true); static void TestDefinePropertyOnDefineGetterSetter
()
{
6610 v8::Isolate* isolate = CcTest::isolate();
6611 v8::HandleScope scope(isolate);
6612 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6613 templ->SetAccessor(v8_str("x"), GetXValue, NULL__null, v8_str("donut"));
6614 LocalContext context;
6615 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6618, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6616 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6618, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6617 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6618, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6618 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6618, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6619
6620 Local<Script> script_desc = v8_compile(
6621 "var prop ="
6622 "Object.getOwnPropertyDescriptor( "
6623 "obj, 'x');"
6624 "prop.configurable;");
6625 Local<Value> result = script_desc->Run(context.local()).ToLocalChecked();
6626 CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result
->BooleanValue(context.local()).FromJust()), (true), "result->BooleanValue(context.local()).FromJust()"
" " "==" " " "true")) { V8_Fatal("../test/cctest/test-api.cc"
, 6626, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6627
6628 Local<Script> script_define = v8_compile(
6629 "var desc = {get: function(){return 42; },"
6630 " configurable: true };"
6631 "Object.defineProperty(obj, 'x', desc);"
6632 "obj.x");
6633 result = script_define->Run(context.local()).ToLocalChecked();
6634 CHECK(result->Equals(context.local(), v8_num(42)).FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context.local
(), v8_num(42)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6634, "Check failed: %s.", "result->Equals(context.local(), v8_num(42)).FromJust()"
); } } while (0)
;
6635
6636 result = script_desc->Run(context.local()).ToLocalChecked();
6637 CHECK_EQ(result->BooleanValue(context.local()).FromJust(), true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result
->BooleanValue(context.local()).FromJust()), (true), "result->BooleanValue(context.local()).FromJust()"
" " "==" " " "true")) { V8_Fatal("../test/cctest/test-api.cc"
, 6637, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6638
6639 script_define = v8_compile(
6640 "var desc = {get: function(){return 43; },"
6641 " configurable: false };"
6642 "Object.defineProperty(obj, 'x', desc);"
6643 "obj.x");
6644 result = script_define->Run(context.local()).ToLocalChecked();
6645 CHECK(result->Equals(context.local(), v8_num(43)).FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context.local
(), v8_num(43)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6645, "Check failed: %s.", "result->Equals(context.local(), v8_num(43)).FromJust()"
); } } while (0)
;
6646
6647 result = script_desc->Run(context.local()).ToLocalChecked();
6648 CHECK_EQ(result->BooleanValue(context.local()).FromJust(), false)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result
->BooleanValue(context.local()).FromJust()), (false), "result->BooleanValue(context.local()).FromJust()"
" " "==" " " "false")) { V8_Fatal("../test/cctest/test-api.cc"
, 6648, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
6649
6650 v8::TryCatch try_catch(isolate);
6651 CHECK(script_define->Run(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script_define->Run(context
.local()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6651, "Check failed: %s.", "script_define->Run(context.local()).IsEmpty()"
); } } while (0)
;
6652 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6652, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6653 String::Utf8Value exception_value(try_catch.Exception());
6654 CHECK_EQ(0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "TypeError: Cannot redefine property: x"))
, "0" " " "==" " " "strcmp(*exception_value, \"TypeError: Cannot redefine property: x\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6655, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6655 strcmp(*exception_value, "TypeError: Cannot redefine property: x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "TypeError: Cannot redefine property: x"))
, "0" " " "==" " " "strcmp(*exception_value, \"TypeError: Cannot redefine property: x\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6655, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6656}
6657
6658
6659static v8::Local<v8::Object> GetGlobalProperty(LocalContext* context,
6660 char const* name) {
6661 return v8::Local<v8::Object>::Cast(
6662 (*context)
6663 ->Global()
6664 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str(name))
6665 .ToLocalChecked());
6666}
6667
6668
6669THREADED_TEST(DefineAPIAccessorOnObject)static void TestDefineAPIAccessorOnObject(); RegisterThreadedTest
register_DefineAPIAccessorOnObject(TestDefineAPIAccessorOnObject
, "DefineAPIAccessorOnObject"); static void TestDefineAPIAccessorOnObject
(); CcTest register_test_DefineAPIAccessorOnObject(TestDefineAPIAccessorOnObject
, "../test/cctest/test-api.cc", "DefineAPIAccessorOnObject", __null
, true, true); static void TestDefineAPIAccessorOnObject()
{
6670 v8::Isolate* isolate = CcTest::isolate();
6671 v8::HandleScope scope(isolate);
6672 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6673 LocalContext context;
6674
6675 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6678, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6676 ->Set(context.local(), v8_str("obj1"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6678, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6677 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6678, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6678 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6678, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6679 CompileRun("var obj2 = {};");
6680
6681 CHECK(CompileRun("obj1.x")->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRun("obj1.x")->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6681, "Check failed: %s."
, "CompileRun(\"obj1.x\")->IsUndefined()"); } } while (0)
;
6682 CHECK(CompileRun("obj2.x")->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRun("obj2.x")->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6682, "Check failed: %s."
, "CompileRun(\"obj2.x\")->IsUndefined()"); } } while (0)
;
6683
6684 CHECK(GetGlobalProperty(&context, "obj1")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6687, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6685 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6687, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6686 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6687, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6687 .FromJust())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6687, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
;
6688
6689 ExpectString("obj1.x", "x");
6690 CHECK(CompileRun("obj2.x")->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRun("obj2.x")->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6690, "Check failed: %s."
, "CompileRun(\"obj2.x\")->IsUndefined()"); } } while (0)
;
6691
6692 CHECK(GetGlobalProperty(&context, "obj2")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6695, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6693 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6695, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6694 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6695, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6695 .FromJust())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6695, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
;
6696
6697 ExpectString("obj1.x", "x");
6698 ExpectString("obj2.x", "x");
6699
6700 ExpectTrue("Object.getOwnPropertyDescriptor(obj1, 'x').configurable");
6701 ExpectTrue("Object.getOwnPropertyDescriptor(obj2, 'x').configurable");
6702
6703 CompileRun(
6704 "Object.defineProperty(obj1, 'x',"
6705 "{ get: function() { return 'y'; }, configurable: true })");
6706
6707 ExpectString("obj1.x", "y");
6708 ExpectString("obj2.x", "x");
6709
6710 CompileRun(
6711 "Object.defineProperty(obj2, 'x',"
6712 "{ get: function() { return 'y'; }, configurable: true })");
6713
6714 ExpectString("obj1.x", "y");
6715 ExpectString("obj2.x", "y");
6716
6717 ExpectTrue("Object.getOwnPropertyDescriptor(obj1, 'x').configurable");
6718 ExpectTrue("Object.getOwnPropertyDescriptor(obj2, 'x').configurable");
6719
6720 CHECK(GetGlobalProperty(&context, "obj1")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6723, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6721 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6723, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6722 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6723, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6723 .FromJust())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6723, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
;
6724 CHECK(GetGlobalProperty(&context, "obj2")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6727, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6725 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6727, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6726 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6727, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6727 .FromJust())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6727, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
;
6728
6729 ExpectString("obj1.x", "x");
6730 ExpectString("obj2.x", "x");
6731
6732 ExpectTrue("Object.getOwnPropertyDescriptor(obj1, 'x').configurable");
6733 ExpectTrue("Object.getOwnPropertyDescriptor(obj2, 'x').configurable");
6734
6735 // Define getters/setters, but now make them not configurable.
6736 CompileRun(
6737 "Object.defineProperty(obj1, 'x',"
6738 "{ get: function() { return 'z'; }, configurable: false })");
6739 CompileRun(
6740 "Object.defineProperty(obj2, 'x',"
6741 "{ get: function() { return 'z'; }, configurable: false })");
6742 ExpectTrue("!Object.getOwnPropertyDescriptor(obj1, 'x').configurable");
6743 ExpectTrue("!Object.getOwnPropertyDescriptor(obj2, 'x').configurable");
6744
6745 ExpectString("obj1.x", "z");
6746 ExpectString("obj2.x", "z");
6747
6748 CHECK(GetGlobalProperty(&context, "obj1")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6751, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6749 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6751, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6750 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6751, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6751 .IsNothing())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6751, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
;
6752 CHECK(GetGlobalProperty(&context, "obj2")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6755, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6753 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6755, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6754 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6755, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6755 .IsNothing())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6755, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
;
6756
6757 ExpectString("obj1.x", "z");
6758 ExpectString("obj2.x", "z");
6759}
6760
6761
6762THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden)static void TestDontDeleteAPIAccessorsCannotBeOverriden(); RegisterThreadedTest
register_DontDeleteAPIAccessorsCannotBeOverriden(TestDontDeleteAPIAccessorsCannotBeOverriden
, "DontDeleteAPIAccessorsCannotBeOverriden"); static void TestDontDeleteAPIAccessorsCannotBeOverriden
(); CcTest register_test_DontDeleteAPIAccessorsCannotBeOverriden
(TestDontDeleteAPIAccessorsCannotBeOverriden, "../test/cctest/test-api.cc"
, "DontDeleteAPIAccessorsCannotBeOverriden", __null, true, true
); static void TestDontDeleteAPIAccessorsCannotBeOverriden()
{
6763 v8::Isolate* isolate = CcTest::isolate();
6764 v8::HandleScope scope(isolate);
6765 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6766 LocalContext context;
6767
6768 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6771, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6769 ->Set(context.local(), v8_str("obj1"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6771, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6770 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6771, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6771 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6771, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6772 CompileRun("var obj2 = {};");
6773
6774 CHECK(GetGlobalProperty(&context, "obj1")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut"), v8::DEFAULT, v8::DontDelete) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6777, "Check failed: %s."
, "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\"), v8::DEFAULT, v8::DontDelete) .FromJust()"
); } } while (0)
6775 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut"), v8::DEFAULT, v8::DontDelete) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6777, "Check failed: %s."
, "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\"), v8::DEFAULT, v8::DontDelete) .FromJust()"
); } } while (0)
6776 v8_str("donut"), v8::DEFAULT, v8::DontDelete)do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut"), v8::DEFAULT, v8::DontDelete) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6777, "Check failed: %s."
, "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\"), v8::DEFAULT, v8::DontDelete) .FromJust()"
); } } while (0)
6777 .FromJust())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut"), v8::DEFAULT, v8::DontDelete) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6777, "Check failed: %s."
, "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\"), v8::DEFAULT, v8::DontDelete) .FromJust()"
); } } while (0)
;
6778 CHECK(GetGlobalProperty(&context, "obj2")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut"), v8::DEFAULT, v8::DontDelete) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6781, "Check failed: %s."
, "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\"), v8::DEFAULT, v8::DontDelete) .FromJust()"
); } } while (0)
6779 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut"), v8::DEFAULT, v8::DontDelete) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6781, "Check failed: %s."
, "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\"), v8::DEFAULT, v8::DontDelete) .FromJust()"
); } } while (0)
6780 v8_str("donut"), v8::DEFAULT, v8::DontDelete)do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut"), v8::DEFAULT, v8::DontDelete) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6781, "Check failed: %s."
, "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\"), v8::DEFAULT, v8::DontDelete) .FromJust()"
); } } while (0)
6781 .FromJust())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut"), v8::DEFAULT, v8::DontDelete) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6781, "Check failed: %s."
, "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\"), v8::DEFAULT, v8::DontDelete) .FromJust()"
); } } while (0)
;
6782
6783 ExpectString("obj1.x", "x");
6784 ExpectString("obj2.x", "x");
6785
6786 ExpectTrue("!Object.getOwnPropertyDescriptor(obj1, 'x').configurable");
6787 ExpectTrue("!Object.getOwnPropertyDescriptor(obj2, 'x').configurable");
6788
6789 CHECK(GetGlobalProperty(&context, "obj1")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6792, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6790 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6792, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6791 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6792, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6792 .IsNothing())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6792, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
;
6793 CHECK(GetGlobalProperty(&context, "obj2")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6796, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6794 ->SetAccessor(context.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6796, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6795 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6796, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
6796 .IsNothing())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("x"), GetXValue
, __null, v8_str("donut")) .IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6796, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"donut\")) .IsNothing()"
); } } while (0)
;
6797
6798 {
6799 v8::TryCatch try_catch(isolate);
6800 CompileRun(
6801 "Object.defineProperty(obj1, 'x',"
6802 "{get: function() { return 'func'; }})");
6803 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6803, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6804 String::Utf8Value exception_value(try_catch.Exception());
6805 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "TypeError: Cannot redefine property: x"))
, "0" " " "==" " " "strcmp(*exception_value, \"TypeError: Cannot redefine property: x\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6806, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6806 0, strcmp(*exception_value, "TypeError: Cannot redefine property: x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "TypeError: Cannot redefine property: x"))
, "0" " " "==" " " "strcmp(*exception_value, \"TypeError: Cannot redefine property: x\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6806, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6807 }
6808 {
6809 v8::TryCatch try_catch(isolate);
6810 CompileRun(
6811 "Object.defineProperty(obj2, 'x',"
6812 "{get: function() { return 'func'; }})");
6813 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 6813, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
6814 String::Utf8Value exception_value(try_catch.Exception());
6815 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "TypeError: Cannot redefine property: x"))
, "0" " " "==" " " "strcmp(*exception_value, \"TypeError: Cannot redefine property: x\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6816, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6816 0, strcmp(*exception_value, "TypeError: Cannot redefine property: x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "TypeError: Cannot redefine property: x"))
, "0" " " "==" " " "strcmp(*exception_value, \"TypeError: Cannot redefine property: x\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 6816, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6817 }
6818}
6819
6820
6821static void Get239Value(Local<Name> name,
6822 const v8::PropertyCallbackInfo<v8::Value>& info) {
6823 ApiTestFuzzer::Fuzz();
6824 CHECK(info.Data()do { if ((__builtin_expect(!!(!(info.Data() ->Equals(info.
GetIsolate()->GetCurrentContext(), v8_str("donut")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6826, "Check failed: %s."
, "info.Data() ->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"donut\")) .FromJust()"
); } } while (0)
6825 ->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("donut"))do { if ((__builtin_expect(!!(!(info.Data() ->Equals(info.
GetIsolate()->GetCurrentContext(), v8_str("donut")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6826, "Check failed: %s."
, "info.Data() ->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"donut\")) .FromJust()"
); } } while (0)
6826 .FromJust())do { if ((__builtin_expect(!!(!(info.Data() ->Equals(info.
GetIsolate()->GetCurrentContext(), v8_str("donut")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 6826, "Check failed: %s."
, "info.Data() ->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"donut\")) .FromJust()"
); } } while (0)
;
6827 CHECK(name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("239"))do { if ((__builtin_expect(!!(!(name->Equals(info.GetIsolate
()->GetCurrentContext(), v8_str("239")) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6828, "Check failed: %s."
, "name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"239\")) .FromJust()"
); } } while (0)
6828 .FromJust())do { if ((__builtin_expect(!!(!(name->Equals(info.GetIsolate
()->GetCurrentContext(), v8_str("239")) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 6828, "Check failed: %s."
, "name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"239\")) .FromJust()"
); } } while (0)
;
6829 info.GetReturnValue().Set(name);
6830}
6831
6832
6833THREADED_TEST(ElementAPIAccessor)static void TestElementAPIAccessor(); RegisterThreadedTest register_ElementAPIAccessor
(TestElementAPIAccessor, "ElementAPIAccessor"); static void TestElementAPIAccessor
(); CcTest register_test_ElementAPIAccessor(TestElementAPIAccessor
, "../test/cctest/test-api.cc", "ElementAPIAccessor", __null,
true, true); static void TestElementAPIAccessor()
{
6834 v8::Isolate* isolate = CcTest::isolate();
6835 v8::HandleScope scope(isolate);
6836 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6837 LocalContext context;
6838
6839 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6842, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6840 ->Set(context.local(), v8_str("obj1"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6842, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6841 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6842, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6842 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj1"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6842, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj1\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6843 CompileRun("var obj2 = {};");
6844
6845 CHECK(GetGlobalProperty(&context, "obj1")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("239"), Get239Value
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6848, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"239\"), Get239Value, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6846 ->SetAccessor(context.local(), v8_str("239"), Get239Value, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("239"), Get239Value
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6848, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"239\"), Get239Value, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6847 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("239"), Get239Value
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6848, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"239\"), Get239Value, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6848 .FromJust())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj1") ->SetAccessor(context.local(), v8_str("239"), Get239Value
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6848, "Check failed: %s.", "GetGlobalProperty(&context, \"obj1\") ->SetAccessor(context.local(), v8_str(\"239\"), Get239Value, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
;
6849 CHECK(GetGlobalProperty(&context, "obj2")do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("239"), Get239Value
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6852, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"239\"), Get239Value, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6850 ->SetAccessor(context.local(), v8_str("239"), Get239Value, NULL,do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("239"), Get239Value
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6852, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"239\"), Get239Value, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6851 v8_str("donut"))do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("239"), Get239Value
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6852, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"239\"), Get239Value, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
6852 .FromJust())do { if ((__builtin_expect(!!(!(GetGlobalProperty(&context
, "obj2") ->SetAccessor(context.local(), v8_str("239"), Get239Value
, __null, v8_str("donut")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6852, "Check failed: %s.", "GetGlobalProperty(&context, \"obj2\") ->SetAccessor(context.local(), v8_str(\"239\"), Get239Value, NULL, v8_str(\"donut\")) .FromJust()"
); } } while (0)
;
6853
6854 ExpectString("obj1[239]", "239");
6855 ExpectString("obj2[239]", "239");
6856 ExpectString("obj1['239']", "239");
6857 ExpectString("obj2['239']", "239");
6858}
6859
6860
6861v8::Persistent<Value> xValue;
6862
6863
6864static void SetXValue(Local<Name> name, Local<Value> value,
6865 const v8::PropertyCallbackInfo<void>& info) {
6866 Local<Context> context = info.GetIsolate()->GetCurrentContext();
6867 CHECK(value->Equals(context, v8_num(4)).FromJust())do { if ((__builtin_expect(!!(!(value->Equals(context, v8_num
(4)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6867, "Check failed: %s.", "value->Equals(context, v8_num(4)).FromJust()"
); } } while (0)
;
6868 CHECK(info.Data()->Equals(context, v8_str("donut")).FromJust())do { if ((__builtin_expect(!!(!(info.Data()->Equals(context
, v8_str("donut")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6868, "Check failed: %s.", "info.Data()->Equals(context, v8_str(\"donut\")).FromJust()"
); } } while (0)
;
6869 CHECK(name->Equals(context, v8_str("x")).FromJust())do { if ((__builtin_expect(!!(!(name->Equals(context, v8_str
("x")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6869, "Check failed: %s.", "name->Equals(context, v8_str(\"x\")).FromJust()"
); } } while (0)
;
6870 CHECK(xValue.IsEmpty())do { if ((__builtin_expect(!!(!(xValue.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6870, "Check failed: %s.", "xValue.IsEmpty()"
); } } while (0)
;
6871 xValue.Reset(info.GetIsolate(), value);
6872}
6873
6874
6875THREADED_TEST(SimplePropertyWrite)static void TestSimplePropertyWrite(); RegisterThreadedTest register_SimplePropertyWrite
(TestSimplePropertyWrite, "SimplePropertyWrite"); static void
TestSimplePropertyWrite(); CcTest register_test_SimplePropertyWrite
(TestSimplePropertyWrite, "../test/cctest/test-api.cc", "SimplePropertyWrite"
, __null, true, true); static void TestSimplePropertyWrite()
{
6876 v8::Isolate* isolate = CcTest::isolate();
6877 v8::HandleScope scope(isolate);
6878 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6879 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut"));
6880 LocalContext context;
6881 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6884, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6882 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6884, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6883 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6884, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6884 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6884, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6885 Local<Script> script = v8_compile("obj.x = 4");
6886 for (int i = 0; i < 10; i++) {
6887 CHECK(xValue.IsEmpty())do { if ((__builtin_expect(!!(!(xValue.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6887, "Check failed: %s.", "xValue.IsEmpty()"
); } } while (0)
;
6888 script->Run(context.local()).ToLocalChecked();
6889 CHECK(v8_num(4)do { if ((__builtin_expect(!!(!(v8_num(4) ->Equals(context
.local(), Local<Value>::New(CcTest::isolate(), xValue))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6892, "Check failed: %s.", "v8_num(4) ->Equals(context.local(), Local<Value>::New(CcTest::isolate(), xValue)) .FromJust()"
); } } while (0)
6890 ->Equals(context.local(),do { if ((__builtin_expect(!!(!(v8_num(4) ->Equals(context
.local(), Local<Value>::New(CcTest::isolate(), xValue))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6892, "Check failed: %s.", "v8_num(4) ->Equals(context.local(), Local<Value>::New(CcTest::isolate(), xValue)) .FromJust()"
); } } while (0)
6891 Local<Value>::New(CcTest::isolate(), xValue))do { if ((__builtin_expect(!!(!(v8_num(4) ->Equals(context
.local(), Local<Value>::New(CcTest::isolate(), xValue))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6892, "Check failed: %s.", "v8_num(4) ->Equals(context.local(), Local<Value>::New(CcTest::isolate(), xValue)) .FromJust()"
); } } while (0)
6892 .FromJust())do { if ((__builtin_expect(!!(!(v8_num(4) ->Equals(context
.local(), Local<Value>::New(CcTest::isolate(), xValue))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6892, "Check failed: %s.", "v8_num(4) ->Equals(context.local(), Local<Value>::New(CcTest::isolate(), xValue)) .FromJust()"
); } } while (0)
;
6893 xValue.Reset();
6894 }
6895}
6896
6897
6898THREADED_TEST(SetterOnly)static void TestSetterOnly(); RegisterThreadedTest register_SetterOnly
(TestSetterOnly, "SetterOnly"); static void TestSetterOnly();
CcTest register_test_SetterOnly(TestSetterOnly, "../test/cctest/test-api.cc"
, "SetterOnly", __null, true, true); static void TestSetterOnly
()
{
6899 v8::Isolate* isolate = CcTest::isolate();
6900 v8::HandleScope scope(isolate);
6901 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6902 templ->SetAccessor(v8_str("x"), NULL__null, SetXValue, v8_str("donut"));
6903 LocalContext context;
6904 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6907, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6905 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6907, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6906 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6907, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6907 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6907, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6908 Local<Script> script = v8_compile("obj.x = 4; obj.x");
6909 for (int i = 0; i < 10; i++) {
6910 CHECK(xValue.IsEmpty())do { if ((__builtin_expect(!!(!(xValue.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6910, "Check failed: %s.", "xValue.IsEmpty()"
); } } while (0)
;
6911 script->Run(context.local()).ToLocalChecked();
6912 CHECK(v8_num(4)do { if ((__builtin_expect(!!(!(v8_num(4) ->Equals(context
.local(), Local<Value>::New(CcTest::isolate(), xValue))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6915, "Check failed: %s.", "v8_num(4) ->Equals(context.local(), Local<Value>::New(CcTest::isolate(), xValue)) .FromJust()"
); } } while (0)
6913 ->Equals(context.local(),do { if ((__builtin_expect(!!(!(v8_num(4) ->Equals(context
.local(), Local<Value>::New(CcTest::isolate(), xValue))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6915, "Check failed: %s.", "v8_num(4) ->Equals(context.local(), Local<Value>::New(CcTest::isolate(), xValue)) .FromJust()"
); } } while (0)
6914 Local<Value>::New(CcTest::isolate(), xValue))do { if ((__builtin_expect(!!(!(v8_num(4) ->Equals(context
.local(), Local<Value>::New(CcTest::isolate(), xValue))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6915, "Check failed: %s.", "v8_num(4) ->Equals(context.local(), Local<Value>::New(CcTest::isolate(), xValue)) .FromJust()"
); } } while (0)
6915 .FromJust())do { if ((__builtin_expect(!!(!(v8_num(4) ->Equals(context
.local(), Local<Value>::New(CcTest::isolate(), xValue))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
6915, "Check failed: %s.", "v8_num(4) ->Equals(context.local(), Local<Value>::New(CcTest::isolate(), xValue)) .FromJust()"
); } } while (0)
;
6916 xValue.Reset();
6917 }
6918}
6919
6920
6921THREADED_TEST(NoAccessors)static void TestNoAccessors(); RegisterThreadedTest register_NoAccessors
(TestNoAccessors, "NoAccessors"); static void TestNoAccessors
(); CcTest register_test_NoAccessors(TestNoAccessors, "../test/cctest/test-api.cc"
, "NoAccessors", __null, true, true); static void TestNoAccessors
()
{
6922 v8::Isolate* isolate = CcTest::isolate();
6923 v8::HandleScope scope(isolate);
6924 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6925 templ->SetAccessor(v8_str("x"), static_cast<v8::AccessorGetterCallback>(NULL__null),
6926 NULL__null, v8_str("donut"));
6927 LocalContext context;
6928 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6931, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6929 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6931, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6930 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6931, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
6931 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6931, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
6932 Local<Script> script = v8_compile("obj.x = 4; obj.x");
6933 for (int i = 0; i < 10; i++) {
6934 script->Run(context.local()).ToLocalChecked();
6935 }
6936}
6937
6938
6939THREADED_TEST(MultiContexts)static void TestMultiContexts(); RegisterThreadedTest register_MultiContexts
(TestMultiContexts, "MultiContexts"); static void TestMultiContexts
(); CcTest register_test_MultiContexts(TestMultiContexts, "../test/cctest/test-api.cc"
, "MultiContexts", __null, true, true); static void TestMultiContexts
()
{
6940 v8::Isolate* isolate = CcTest::isolate();
6941 v8::HandleScope scope(isolate);
6942 v8::Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
6943 templ->Set(v8_str("dummy"),
6944 v8::FunctionTemplate::New(isolate, DummyCallHandler));
6945
6946 Local<String> password = v8_str("Password");
6947
6948 // Create an environment
6949 LocalContext context0(0, templ);
6950 context0->SetSecurityToken(password);
6951 v8::Local<v8::Object> global0 = context0->Global();
6952 CHECK(global0->Set(context0.local(), v8_str("custom"), v8_num(1234))do { if ((__builtin_expect(!!(!(global0->Set(context0.local
(), v8_str("custom"), v8_num(1234)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6953, "Check failed: %s.", "global0->Set(context0.local(), v8_str(\"custom\"), v8_num(1234)) .FromJust()"
); } } while (0)
6953 .FromJust())do { if ((__builtin_expect(!!(!(global0->Set(context0.local
(), v8_str("custom"), v8_num(1234)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6953, "Check failed: %s.", "global0->Set(context0.local(), v8_str(\"custom\"), v8_num(1234)) .FromJust()"
); } } while (0)
;
6954 CHECK_EQ(1234, global0->Get(context0.local(), v8_str("custom"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global0->Get(context0.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context0.local()) .FromJust()), "1234" " "
"==" " " "global0->Get(context0.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6957, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6955 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global0->Get(context0.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context0.local()) .FromJust()), "1234" " "
"==" " " "global0->Get(context0.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6957, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6956 ->Int32Value(context0.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global0->Get(context0.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context0.local()) .FromJust()), "1234" " "
"==" " " "global0->Get(context0.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6957, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6957 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global0->Get(context0.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context0.local()) .FromJust()), "1234" " "
"==" " " "global0->Get(context0.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6957, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6958
6959 // Create an independent environment
6960 LocalContext context1(0, templ);
6961 context1->SetSecurityToken(password);
6962 v8::Local<v8::Object> global1 = context1->Global();
6963 CHECK(global1->Set(context1.local(), v8_str("custom"), v8_num(1234))do { if ((__builtin_expect(!!(!(global1->Set(context1.local
(), v8_str("custom"), v8_num(1234)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6964, "Check failed: %s.", "global1->Set(context1.local(), v8_str(\"custom\"), v8_num(1234)) .FromJust()"
); } } while (0)
6964 .FromJust())do { if ((__builtin_expect(!!(!(global1->Set(context1.local
(), v8_str("custom"), v8_num(1234)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 6964, "Check failed: %s.", "global1->Set(context1.local(), v8_str(\"custom\"), v8_num(1234)) .FromJust()"
); } } while (0)
;
6965 CHECK(!global0->Equals(context1.local(), global1).FromJust())do { if ((__builtin_expect(!!(!(!global0->Equals(context1.
local(), global1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6965, "Check failed: %s.", "!global0->Equals(context1.local(), global1).FromJust()"
); } } while (0)
;
6966 CHECK_EQ(1234, global0->Get(context1.local(), v8_str("custom"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global0->Get(context1.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context0.local()) .FromJust()), "1234" " "
"==" " " "global0->Get(context1.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6969, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6967 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global0->Get(context1.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context0.local()) .FromJust()), "1234" " "
"==" " " "global0->Get(context1.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6969, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6968 ->Int32Value(context0.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global0->Get(context1.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context0.local()) .FromJust()), "1234" " "
"==" " " "global0->Get(context1.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6969, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6969 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global0->Get(context1.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context0.local()) .FromJust()), "1234" " "
"==" " " "global0->Get(context1.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6969, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6970 CHECK_EQ(1234, global1->Get(context1.local(), v8_str("custom"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global1->Get(context1.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context1.local()) .FromJust()), "1234" " "
"==" " " "global1->Get(context1.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6973, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6971 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global1->Get(context1.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context1.local()) .FromJust()), "1234" " "
"==" " " "global1->Get(context1.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6973, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6972 ->Int32Value(context1.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global1->Get(context1.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context1.local()) .FromJust()), "1234" " "
"==" " " "global1->Get(context1.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6973, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6973 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(global1->Get(context1.local(), v8_str("custom")) .ToLocalChecked
() ->Int32Value(context1.local()) .FromJust()), "1234" " "
"==" " " "global1->Get(context1.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6973, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6974
6975 // Now create a new context with the old global
6976 LocalContext context2(0, templ, global1);
6977 context2->SetSecurityToken(password);
6978 v8::Local<v8::Object> global2 = context2->Global();
6979 CHECK(global1->Equals(context2.local(), global2).FromJust())do { if ((__builtin_expect(!!(!(global1->Equals(context2.local
(), global2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 6979, "Check failed: %s.", "global1->Equals(context2.local(), global2).FromJust()"
); } } while (0)
;
6980 CHECK_EQ(0, global1->Get(context2.local(), v8_str("custom"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global1
->Get(context2.local(), v8_str("custom")) .ToLocalChecked(
) ->Int32Value(context1.local()) .FromJust()), "0" " " "=="
" " "global1->Get(context2.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6983, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6981 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global1
->Get(context2.local(), v8_str("custom")) .ToLocalChecked(
) ->Int32Value(context1.local()) .FromJust()), "0" " " "=="
" " "global1->Get(context2.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6983, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6982 ->Int32Value(context1.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global1
->Get(context2.local(), v8_str("custom")) .ToLocalChecked(
) ->Int32Value(context1.local()) .FromJust()), "0" " " "=="
" " "global1->Get(context2.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6983, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6983 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global1
->Get(context2.local(), v8_str("custom")) .ToLocalChecked(
) ->Int32Value(context1.local()) .FromJust()), "0" " " "=="
" " "global1->Get(context2.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6983, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6984 CHECK_EQ(0, global2->Get(context2.local(), v8_str("custom"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global2
->Get(context2.local(), v8_str("custom")) .ToLocalChecked(
) ->Int32Value(context2.local()) .FromJust()), "0" " " "=="
" " "global2->Get(context2.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context2.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6987, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6985 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global2
->Get(context2.local(), v8_str("custom")) .ToLocalChecked(
) ->Int32Value(context2.local()) .FromJust()), "0" " " "=="
" " "global2->Get(context2.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context2.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6987, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6986 ->Int32Value(context2.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global2
->Get(context2.local(), v8_str("custom")) .ToLocalChecked(
) ->Int32Value(context2.local()) .FromJust()), "0" " " "=="
" " "global2->Get(context2.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context2.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6987, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
6987 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global2
->Get(context2.local(), v8_str("custom")) .ToLocalChecked(
) ->Int32Value(context2.local()) .FromJust()), "0" " " "=="
" " "global2->Get(context2.local(), v8_str(\"custom\")) .ToLocalChecked() ->Int32Value(context2.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 6987, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
6988}
6989
6990
6991THREADED_TEST(FunctionPrototypeAcrossContexts)static void TestFunctionPrototypeAcrossContexts(); RegisterThreadedTest
register_FunctionPrototypeAcrossContexts(TestFunctionPrototypeAcrossContexts
, "FunctionPrototypeAcrossContexts"); static void TestFunctionPrototypeAcrossContexts
(); CcTest register_test_FunctionPrototypeAcrossContexts(TestFunctionPrototypeAcrossContexts
, "../test/cctest/test-api.cc", "FunctionPrototypeAcrossContexts"
, __null, true, true); static void TestFunctionPrototypeAcrossContexts
()
{
6992 // Make sure that functions created by cloning boilerplates cannot
6993 // communicate through their __proto__ field.
6994
6995 v8::HandleScope scope(CcTest::isolate());
6996
6997 LocalContext env0;
6998 v8::Local<v8::Object> global0 = env0->Global();
6999 v8::Local<v8::Object> object0 = global0->Get(env0.local(), v8_str("Object"))
7000 .ToLocalChecked()
7001 .As<v8::Object>();
7002 v8::Local<v8::Object> tostring0 =
7003 object0->Get(env0.local(), v8_str("toString"))
7004 .ToLocalChecked()
7005 .As<v8::Object>();
7006 v8::Local<v8::Object> proto0 =
7007 tostring0->Get(env0.local(), v8_str("__proto__"))
7008 .ToLocalChecked()
7009 .As<v8::Object>();
7010 CHECK(proto0->Set(env0.local(), v8_str("custom"), v8_num(1234)).FromJust())do { if ((__builtin_expect(!!(!(proto0->Set(env0.local(), v8_str
("custom"), v8_num(1234)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7010, "Check failed: %s.", "proto0->Set(env0.local(), v8_str(\"custom\"), v8_num(1234)).FromJust()"
); } } while (0)
;
7011
7012 LocalContext env1;
7013 v8::Local<v8::Object> global1 = env1->Global();
7014 v8::Local<v8::Object> object1 = global1->Get(env1.local(), v8_str("Object"))
7015 .ToLocalChecked()
7016 .As<v8::Object>();
7017 v8::Local<v8::Object> tostring1 =
7018 object1->Get(env1.local(), v8_str("toString"))
7019 .ToLocalChecked()
7020 .As<v8::Object>();
7021 v8::Local<v8::Object> proto1 =
7022 tostring1->Get(env1.local(), v8_str("__proto__"))
7023 .ToLocalChecked()
7024 .As<v8::Object>();
7025 CHECK(!proto1->Has(env1.local(), v8_str("custom")).FromJust())do { if ((__builtin_expect(!!(!(!proto1->Has(env1.local(),
v8_str("custom")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7025, "Check failed: %s.", "!proto1->Has(env1.local(), v8_str(\"custom\")).FromJust()"
); } } while (0)
;
7026}
7027
7028
7029THREADED_TEST(Regress892105)static void TestRegress892105(); RegisterThreadedTest register_Regress892105
(TestRegress892105, "Regress892105"); static void TestRegress892105
(); CcTest register_test_Regress892105(TestRegress892105, "../test/cctest/test-api.cc"
, "Regress892105", __null, true, true); static void TestRegress892105
()
{
7030 // Make sure that object and array literals created by cloning
7031 // boilerplates cannot communicate through their __proto__
7032 // field. This is rather difficult to check, but we try to add stuff
7033 // to Object.prototype and Array.prototype and create a new
7034 // environment. This should succeed.
7035
7036 v8::HandleScope scope(CcTest::isolate());
7037
7038 Local<String> source = v8_str(
7039 "Object.prototype.obj = 1234;"
7040 "Array.prototype.arr = 4567;"
7041 "8901");
7042
7043 LocalContext env0;
7044 Local<Script> script0 = v8_compile(source);
7045 CHECK_EQ(8901.0, script0->Run(env0.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8901.0
), (script0->Run(env0.local()) .ToLocalChecked() ->NumberValue
(env0.local()) .FromJust()), "8901.0" " " "==" " " "script0->Run(env0.local()) .ToLocalChecked() ->NumberValue(env0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7048, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
7046 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8901.0
), (script0->Run(env0.local()) .ToLocalChecked() ->NumberValue
(env0.local()) .FromJust()), "8901.0" " " "==" " " "script0->Run(env0.local()) .ToLocalChecked() ->NumberValue(env0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7048, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
7047 ->NumberValue(env0.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8901.0
), (script0->Run(env0.local()) .ToLocalChecked() ->NumberValue
(env0.local()) .FromJust()), "8901.0" " " "==" " " "script0->Run(env0.local()) .ToLocalChecked() ->NumberValue(env0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7048, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
7048 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8901.0
), (script0->Run(env0.local()) .ToLocalChecked() ->NumberValue
(env0.local()) .FromJust()), "8901.0" " " "==" " " "script0->Run(env0.local()) .ToLocalChecked() ->NumberValue(env0.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7048, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
7049
7050 LocalContext env1;
7051 Local<Script> script1 = v8_compile(source);
7052 CHECK_EQ(8901.0, script1->Run(env1.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8901.0
), (script1->Run(env1.local()) .ToLocalChecked() ->NumberValue
(env1.local()) .FromJust()), "8901.0" " " "==" " " "script1->Run(env1.local()) .ToLocalChecked() ->NumberValue(env1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7055, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
7053 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8901.0
), (script1->Run(env1.local()) .ToLocalChecked() ->NumberValue
(env1.local()) .FromJust()), "8901.0" " " "==" " " "script1->Run(env1.local()) .ToLocalChecked() ->NumberValue(env1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7055, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
7054 ->NumberValue(env1.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8901.0
), (script1->Run(env1.local()) .ToLocalChecked() ->NumberValue
(env1.local()) .FromJust()), "8901.0" " " "==" " " "script1->Run(env1.local()) .ToLocalChecked() ->NumberValue(env1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7055, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
7055 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8901.0
), (script1->Run(env1.local()) .ToLocalChecked() ->NumberValue
(env1.local()) .FromJust()), "8901.0" " " "==" " " "script1->Run(env1.local()) .ToLocalChecked() ->NumberValue(env1.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7055, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
7056}
7057
7058
7059THREADED_TEST(UndetectableObject)static void TestUndetectableObject(); RegisterThreadedTest register_UndetectableObject
(TestUndetectableObject, "UndetectableObject"); static void TestUndetectableObject
(); CcTest register_test_UndetectableObject(TestUndetectableObject
, "../test/cctest/test-api.cc", "UndetectableObject", __null,
true, true); static void TestUndetectableObject()
{
7060 LocalContext env;
7061 v8::HandleScope scope(env->GetIsolate());
7062
7063 Local<v8::FunctionTemplate> desc =
7064 v8::FunctionTemplate::New(env->GetIsolate());
7065 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
7066
7067 Local<v8::Object> obj = desc->GetFunction(env.local())
7068 .ToLocalChecked()
7069 ->NewInstance(env.local())
7070 .ToLocalChecked();
7071 CHECK(do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("undetectable"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7072, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"undetectable\"), obj).FromJust()"
); } } while (0)
7072 env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("undetectable"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7072, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"undetectable\"), obj).FromJust()"
); } } while (0)
;
7073
7074 ExpectString("undetectable.toString()", "[object Object]");
7075 ExpectString("typeof undetectable", "undefined");
7076 ExpectString("typeof(undetectable)", "undefined");
7077 ExpectBoolean("typeof undetectable == 'undefined'", true);
7078 ExpectBoolean("typeof undetectable == 'object'", false);
7079 ExpectBoolean("if (undetectable) { true; } else { false; }", false);
7080 ExpectBoolean("!undetectable", true);
7081
7082 ExpectObject("true&&undetectable", obj);
7083 ExpectBoolean("false&&undetectable", false);
7084 ExpectBoolean("true||undetectable", true);
7085 ExpectObject("false||undetectable", obj);
7086
7087 ExpectObject("undetectable&&true", obj);
7088 ExpectObject("undetectable&&false", obj);
7089 ExpectBoolean("undetectable||true", true);
7090 ExpectBoolean("undetectable||false", false);
7091
7092 ExpectBoolean("undetectable==null", true);
7093 ExpectBoolean("null==undetectable", true);
7094 ExpectBoolean("undetectable==undefined", true);
7095 ExpectBoolean("undefined==undetectable", true);
7096 ExpectBoolean("undetectable==undetectable", true);
7097
7098
7099 ExpectBoolean("undetectable===null", false);
7100 ExpectBoolean("null===undetectable", false);
7101 ExpectBoolean("undetectable===undefined", false);
7102 ExpectBoolean("undefined===undetectable", false);
7103 ExpectBoolean("undetectable===undetectable", true);
7104}
7105
7106
7107THREADED_TEST(VoidLiteral)static void TestVoidLiteral(); RegisterThreadedTest register_VoidLiteral
(TestVoidLiteral, "VoidLiteral"); static void TestVoidLiteral
(); CcTest register_test_VoidLiteral(TestVoidLiteral, "../test/cctest/test-api.cc"
, "VoidLiteral", __null, true, true); static void TestVoidLiteral
()
{
7108 LocalContext env;
7109 v8::Isolate* isolate = env->GetIsolate();
7110 v8::HandleScope scope(isolate);
7111
7112 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate);
7113 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
7114
7115 Local<v8::Object> obj = desc->GetFunction(env.local())
7116 .ToLocalChecked()
7117 ->NewInstance(env.local())
7118 .ToLocalChecked();
7119 CHECK(do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("undetectable"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7120, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"undetectable\"), obj).FromJust()"
); } } while (0)
7120 env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("undetectable"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7120, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"undetectable\"), obj).FromJust()"
); } } while (0)
;
7121
7122 ExpectBoolean("undefined == void 0", true);
7123 ExpectBoolean("undetectable == void 0", true);
7124 ExpectBoolean("null == void 0", true);
7125 ExpectBoolean("undefined === void 0", true);
7126 ExpectBoolean("undetectable === void 0", false);
7127 ExpectBoolean("null === void 0", false);
7128
7129 ExpectBoolean("void 0 == undefined", true);
7130 ExpectBoolean("void 0 == undetectable", true);
7131 ExpectBoolean("void 0 == null", true);
7132 ExpectBoolean("void 0 === undefined", true);
7133 ExpectBoolean("void 0 === undetectable", false);
7134 ExpectBoolean("void 0 === null", false);
7135
7136 ExpectString(
7137 "(function() {"
7138 " try {"
7139 " return x === void 0;"
7140 " } catch(e) {"
7141 " return e.toString();"
7142 " }"
7143 "})()",
7144 "ReferenceError: x is not defined");
7145 ExpectString(
7146 "(function() {"
7147 " try {"
7148 " return void 0 === x;"
7149 " } catch(e) {"
7150 " return e.toString();"
7151 " }"
7152 "})()",
7153 "ReferenceError: x is not defined");
7154}
7155
7156
7157THREADED_TEST(ExtensibleOnUndetectable)static void TestExtensibleOnUndetectable(); RegisterThreadedTest
register_ExtensibleOnUndetectable(TestExtensibleOnUndetectable
, "ExtensibleOnUndetectable"); static void TestExtensibleOnUndetectable
(); CcTest register_test_ExtensibleOnUndetectable(TestExtensibleOnUndetectable
, "../test/cctest/test-api.cc", "ExtensibleOnUndetectable", __null
, true, true); static void TestExtensibleOnUndetectable()
{
7158 LocalContext env;
7159 v8::Isolate* isolate = env->GetIsolate();
7160 v8::HandleScope scope(isolate);
7161
7162 Local<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate);
7163 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
7164
7165 Local<v8::Object> obj = desc->GetFunction(env.local())
7166 .ToLocalChecked()
7167 ->NewInstance(env.local())
7168 .ToLocalChecked();
7169 CHECK(do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("undetectable"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7170, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"undetectable\"), obj).FromJust()"
); } } while (0)
7170 env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("undetectable"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7170, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"undetectable\"), obj).FromJust()"
); } } while (0)
;
7171
7172 Local<String> source = v8_str(
7173 "undetectable.x = 42;"
7174 "undetectable.x");
7175
7176 Local<Script> script = v8_compile(source);
7177
7178 CHECK(v8::Integer::New(isolate, 42)do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 42)
->Equals(env.local(), script->Run(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7180, "Check failed: %s.", "v8::Integer::New(isolate, 42) ->Equals(env.local(), script->Run(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
7179 ->Equals(env.local(), script->Run(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 42)
->Equals(env.local(), script->Run(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7180, "Check failed: %s.", "v8::Integer::New(isolate, 42) ->Equals(env.local(), script->Run(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
7180 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 42)
->Equals(env.local(), script->Run(env.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7180, "Check failed: %s.", "v8::Integer::New(isolate, 42) ->Equals(env.local(), script->Run(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
7181
7182 ExpectBoolean("Object.isExtensible(undetectable)", true);
7183
7184 source = v8_str("Object.preventExtensions(undetectable);");
7185 script = v8_compile(source);
7186 script->Run(env.local()).ToLocalChecked();
7187 ExpectBoolean("Object.isExtensible(undetectable)", false);
7188
7189 source = v8_str("undetectable.y = 2000;");
7190 script = v8_compile(source);
7191 script->Run(env.local()).ToLocalChecked();
7192 ExpectBoolean("undetectable.y == undefined", true);
7193}
7194
7195
7196// The point of this test is type checking. We run it only so compilers
7197// don't complain about an unused function.
7198TEST(PersistentHandles)static void TestPersistentHandles(); CcTest register_test_PersistentHandles
(TestPersistentHandles, "../test/cctest/test-api.cc", "PersistentHandles"
, __null, true, true); static void TestPersistentHandles()
{
7199 LocalContext env;
7200 v8::Isolate* isolate = CcTest::isolate();
7201 v8::HandleScope scope(isolate);
7202 Local<String> str = v8_str("foo");
7203 v8::Persistent<String> p_str(isolate, str);
7204 p_str.Reset();
7205 Local<Script> scr = v8_compile("");
7206 v8::Persistent<Script> p_scr(isolate, scr);
7207 p_scr.Reset();
7208 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
7209 v8::Persistent<ObjectTemplate> p_templ(isolate, templ);
7210 p_templ.Reset();
7211}
7212
7213
7214static void HandleLogDelegator(
7215 const v8::FunctionCallbackInfo<v8::Value>& args) {
7216 ApiTestFuzzer::Fuzz();
7217}
7218
7219
7220THREADED_TEST(GlobalObjectTemplate)static void TestGlobalObjectTemplate(); RegisterThreadedTest register_GlobalObjectTemplate
(TestGlobalObjectTemplate, "GlobalObjectTemplate"); static void
TestGlobalObjectTemplate(); CcTest register_test_GlobalObjectTemplate
(TestGlobalObjectTemplate, "../test/cctest/test-api.cc", "GlobalObjectTemplate"
, __null, true, true); static void TestGlobalObjectTemplate()
{
7221 v8::Isolate* isolate = CcTest::isolate();
7222 v8::HandleScope handle_scope(isolate);
7223 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
7224 global_template->Set(v8_str("JSNI_Log"),
7225 v8::FunctionTemplate::New(isolate, HandleLogDelegator));
7226 v8::Local<Context> context = Context::New(isolate, 0, global_template);
7227 Context::Scope context_scope(context);
7228 CompileRun("JSNI_Log('LOG')");
7229}
7230
7231
7232static const char* kSimpleExtensionSource =
7233 "function Foo() {"
7234 " return 4;"
7235 "}";
7236
7237
7238TEST(SimpleExtensions)static void TestSimpleExtensions(); CcTest register_test_SimpleExtensions
(TestSimpleExtensions, "../test/cctest/test-api.cc", "SimpleExtensions"
, __null, true, true); static void TestSimpleExtensions()
{
7239 v8::HandleScope handle_scope(CcTest::isolate());
7240 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource));
7241 const char* extension_names[] = {"simpletest"};
7242 v8::ExtensionConfiguration extensions(1, extension_names);
7243 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7244 Context::Scope lock(context);
7245 v8::Local<Value> result = CompileRun("Foo()");
7246 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 4))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 4)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7247, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 4)) .FromJust()"
); } } while (0)
7247 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 4)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7247, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 4)) .FromJust()"
); } } while (0)
;
7248}
7249
7250
7251static const char* kStackTraceFromExtensionSource =
7252 "function foo() {"
7253 " throw new Error();"
7254 "}"
7255 "function bar() {"
7256 " foo();"
7257 "}";
7258
7259
7260TEST(StackTraceInExtension)static void TestStackTraceInExtension(); CcTest register_test_StackTraceInExtension
(TestStackTraceInExtension, "../test/cctest/test-api.cc", "StackTraceInExtension"
, __null, true, true); static void TestStackTraceInExtension(
)
{
7261 v8::HandleScope handle_scope(CcTest::isolate());
7262 v8::RegisterExtension(
7263 new Extension("stacktracetest", kStackTraceFromExtensionSource));
7264 const char* extension_names[] = {"stacktracetest"};
7265 v8::ExtensionConfiguration extensions(1, extension_names);
7266 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7267 Context::Scope lock(context);
7268 CompileRun(
7269 "function user() { bar(); }"
7270 "var error;"
7271 "try{ user(); } catch (e) { error = e; }");
7272 CHECK_EQ(-1, v8_run_int32value(v8_compile("error.stack.indexOf('foo')")))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-1), (
v8_run_int32value(v8_compile("error.stack.indexOf('foo')"))),
"-1" " " "==" " " "v8_run_int32value(v8_compile(\"error.stack.indexOf('foo')\"))"
)) { V8_Fatal("../test/cctest/test-api.cc", 7272, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
7273 CHECK_EQ(-1, v8_run_int32value(v8_compile("error.stack.indexOf('bar')")))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-1), (
v8_run_int32value(v8_compile("error.stack.indexOf('bar')"))),
"-1" " " "==" " " "v8_run_int32value(v8_compile(\"error.stack.indexOf('bar')\"))"
)) { V8_Fatal("../test/cctest/test-api.cc", 7273, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
7274 CHECK_NE(-1, v8_run_int32value(v8_compile("error.stack.indexOf('user')")))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (-1), (
v8_run_int32value(v8_compile("error.stack.indexOf('user')")))
, "-1" " " "!=" " " "v8_run_int32value(v8_compile(\"error.stack.indexOf('user')\"))"
)) { V8_Fatal("../test/cctest/test-api.cc", 7274, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
7275}
7276
7277
7278TEST(NullExtensions)static void TestNullExtensions(); CcTest register_test_NullExtensions
(TestNullExtensions, "../test/cctest/test-api.cc", "NullExtensions"
, __null, true, true); static void TestNullExtensions()
{
7279 v8::HandleScope handle_scope(CcTest::isolate());
7280 v8::RegisterExtension(new Extension("nulltest", NULL__null));
7281 const char* extension_names[] = {"nulltest"};
7282 v8::ExtensionConfiguration extensions(1, extension_names);
7283 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7284 Context::Scope lock(context);
7285 v8::Local<Value> result = CompileRun("1+3");
7286 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 4))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 4)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7287, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 4)) .FromJust()"
); } } while (0)
7287 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 4)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7287, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 4)) .FromJust()"
); } } while (0)
;
7288}
7289
7290
7291static const char* kEmbeddedExtensionSource =
7292 "function Ret54321(){return 54321;}~~@@$"
7293 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS.";
7294static const int kEmbeddedExtensionSourceValidLen = 34;
7295
7296
7297TEST(ExtensionMissingSourceLength)static void TestExtensionMissingSourceLength(); CcTest register_test_ExtensionMissingSourceLength
(TestExtensionMissingSourceLength, "../test/cctest/test-api.cc"
, "ExtensionMissingSourceLength", __null, true, true); static
void TestExtensionMissingSourceLength()
{
7298 v8::HandleScope handle_scope(CcTest::isolate());
7299 v8::RegisterExtension(
7300 new Extension("srclentest_fail", kEmbeddedExtensionSource));
7301 const char* extension_names[] = {"srclentest_fail"};
7302 v8::ExtensionConfiguration extensions(1, extension_names);
7303 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7304 CHECK(0 == *context)do { if ((__builtin_expect(!!(!(0 == *context)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7304, "Check failed: %s.", "0 == *context"
); } } while (0)
;
7305}
7306
7307
7308TEST(ExtensionWithSourceLength)static void TestExtensionWithSourceLength(); CcTest register_test_ExtensionWithSourceLength
(TestExtensionWithSourceLength, "../test/cctest/test-api.cc",
"ExtensionWithSourceLength", __null, true, true); static void
TestExtensionWithSourceLength()
{
7309 for (int source_len = kEmbeddedExtensionSourceValidLen - 1;
7310 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) {
7311 v8::HandleScope handle_scope(CcTest::isolate());
7312 i::ScopedVector<char> extension_name(32);
7313 i::SNPrintF(extension_name, "ext #%d", source_len);
7314 v8::RegisterExtension(new Extension(
7315 extension_name.start(), kEmbeddedExtensionSource, 0, 0, source_len));
7316 const char* extension_names[1] = {extension_name.start()};
7317 v8::ExtensionConfiguration extensions(1, extension_names);
7318 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7319 if (source_len == kEmbeddedExtensionSourceValidLen) {
7320 Context::Scope lock(context);
7321 v8::Local<Value> result = CompileRun("Ret54321()");
7322 CHECK(v8::Integer::New(CcTest::isolate(), 54321)do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 54321) ->Equals(context, result) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7324, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 54321) ->Equals(context, result) .FromJust()"
); } } while (0)
7323 ->Equals(context, result)do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 54321) ->Equals(context, result) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7324, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 54321) ->Equals(context, result) .FromJust()"
); } } while (0)
7324 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 54321) ->Equals(context, result) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7324, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 54321) ->Equals(context, result) .FromJust()"
); } } while (0)
;
7325 } else {
7326 // Anything but exactly the right length should fail to compile.
7327 CHECK(0 == *context)do { if ((__builtin_expect(!!(!(0 == *context)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7327, "Check failed: %s.", "0 == *context"
); } } while (0)
;
7328 }
7329 }
7330}
7331
7332
7333static const char* kEvalExtensionSource1 =
7334 "function UseEval1() {"
7335 " var x = 42;"
7336 " return eval('x');"
7337 "}";
7338
7339
7340static const char* kEvalExtensionSource2 =
7341 "(function() {"
7342 " var x = 42;"
7343 " function e() {"
7344 " return eval('x');"
7345 " }"
7346 " this.UseEval2 = e;"
7347 "})()";
7348
7349
7350TEST(UseEvalFromExtension)static void TestUseEvalFromExtension(); CcTest register_test_UseEvalFromExtension
(TestUseEvalFromExtension, "../test/cctest/test-api.cc", "UseEvalFromExtension"
, __null, true, true); static void TestUseEvalFromExtension()
{
7351 v8::HandleScope handle_scope(CcTest::isolate());
7352 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1));
7353 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2));
7354 const char* extension_names[] = {"evaltest1", "evaltest2"};
7355 v8::ExtensionConfiguration extensions(2, extension_names);
7356 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7357 Context::Scope lock(context);
7358 v8::Local<Value> result = CompileRun("UseEval1()");
7359 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 42))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7360, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 42)) .FromJust()"
); } } while (0)
7360 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7360, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 42)) .FromJust()"
); } } while (0)
;
7361 result = CompileRun("UseEval2()");
7362 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 42))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7363, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 42)) .FromJust()"
); } } while (0)
7363 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7363, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 42)) .FromJust()"
); } } while (0)
;
7364}
7365
7366
7367static const char* kWithExtensionSource1 =
7368 "function UseWith1() {"
7369 " var x = 42;"
7370 " with({x:87}) { return x; }"
7371 "}";
7372
7373
7374static const char* kWithExtensionSource2 =
7375 "(function() {"
7376 " var x = 42;"
7377 " function e() {"
7378 " with ({x:87}) { return x; }"
7379 " }"
7380 " this.UseWith2 = e;"
7381 "})()";
7382
7383
7384TEST(UseWithFromExtension)static void TestUseWithFromExtension(); CcTest register_test_UseWithFromExtension
(TestUseWithFromExtension, "../test/cctest/test-api.cc", "UseWithFromExtension"
, __null, true, true); static void TestUseWithFromExtension()
{
7385 v8::HandleScope handle_scope(CcTest::isolate());
7386 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1));
7387 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2));
7388 const char* extension_names[] = {"withtest1", "withtest2"};
7389 v8::ExtensionConfiguration extensions(2, extension_names);
7390 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7391 Context::Scope lock(context);
7392 v8::Local<Value> result = CompileRun("UseWith1()");
7393 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 87))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 87)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7394, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 87)) .FromJust()"
); } } while (0)
7394 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 87)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7394, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 87)) .FromJust()"
); } } while (0)
;
7395 result = CompileRun("UseWith2()");
7396 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 87))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 87)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7397, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 87)) .FromJust()"
); } } while (0)
7397 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 87)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7397, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 87)) .FromJust()"
); } } while (0)
;
7398}
7399
7400
7401TEST(AutoExtensions)static void TestAutoExtensions(); CcTest register_test_AutoExtensions
(TestAutoExtensions, "../test/cctest/test-api.cc", "AutoExtensions"
, __null, true, true); static void TestAutoExtensions()
{
7402 v8::HandleScope handle_scope(CcTest::isolate());
7403 Extension* extension = new Extension("autotest", kSimpleExtensionSource);
7404 extension->set_auto_enable(true);
7405 v8::RegisterExtension(extension);
7406 v8::Local<Context> context = Context::New(CcTest::isolate());
7407 Context::Scope lock(context);
7408 v8::Local<Value> result = CompileRun("Foo()");
7409 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 4))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 4)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7410, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 4)) .FromJust()"
); } } while (0)
7410 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 4)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7410, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 4)) .FromJust()"
); } } while (0)
;
7411}
7412
7413
7414static const char* kSyntaxErrorInExtensionSource = "[";
7415
7416
7417// Test that a syntax error in an extension does not cause a fatal
7418// error but results in an empty context.
7419TEST(SyntaxErrorExtensions)static void TestSyntaxErrorExtensions(); CcTest register_test_SyntaxErrorExtensions
(TestSyntaxErrorExtensions, "../test/cctest/test-api.cc", "SyntaxErrorExtensions"
, __null, true, true); static void TestSyntaxErrorExtensions(
)
{
7420 v8::HandleScope handle_scope(CcTest::isolate());
7421 v8::RegisterExtension(
7422 new Extension("syntaxerror", kSyntaxErrorInExtensionSource));
7423 const char* extension_names[] = {"syntaxerror"};
7424 v8::ExtensionConfiguration extensions(1, extension_names);
7425 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7426 CHECK(context.IsEmpty())do { if ((__builtin_expect(!!(!(context.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7426, "Check failed: %s.", "context.IsEmpty()"
); } } while (0)
;
7427}
7428
7429
7430static const char* kExceptionInExtensionSource = "throw 42";
7431
7432
7433// Test that an exception when installing an extension does not cause
7434// a fatal error but results in an empty context.
7435TEST(ExceptionExtensions)static void TestExceptionExtensions(); CcTest register_test_ExceptionExtensions
(TestExceptionExtensions, "../test/cctest/test-api.cc", "ExceptionExtensions"
, __null, true, true); static void TestExceptionExtensions()
{
7436 v8::HandleScope handle_scope(CcTest::isolate());
7437 v8::RegisterExtension(
7438 new Extension("exception", kExceptionInExtensionSource));
7439 const char* extension_names[] = {"exception"};
7440 v8::ExtensionConfiguration extensions(1, extension_names);
7441 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7442 CHECK(context.IsEmpty())do { if ((__builtin_expect(!!(!(context.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7442, "Check failed: %s.", "context.IsEmpty()"
); } } while (0)
;
7443}
7444
7445
7446static const char* kNativeCallInExtensionSource =
7447 "function call_runtime_last_index_of(x) {"
7448 " return %StringLastIndexOf(x, 'bob', 10);"
7449 "}";
7450
7451
7452static const char* kNativeCallTest =
7453 "call_runtime_last_index_of('bobbobboellebobboellebobbob');";
7454
7455// Test that a native runtime calls are supported in extensions.
7456TEST(NativeCallInExtensions)static void TestNativeCallInExtensions(); CcTest register_test_NativeCallInExtensions
(TestNativeCallInExtensions, "../test/cctest/test-api.cc", "NativeCallInExtensions"
, __null, true, true); static void TestNativeCallInExtensions
()
{
7457 v8::HandleScope handle_scope(CcTest::isolate());
7458 v8::RegisterExtension(
7459 new Extension("nativecall", kNativeCallInExtensionSource));
7460 const char* extension_names[] = {"nativecall"};
7461 v8::ExtensionConfiguration extensions(1, extension_names);
7462 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7463 Context::Scope lock(context);
7464 v8::Local<Value> result = CompileRun(kNativeCallTest);
7465 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 3))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 3)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7466, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 3)) .FromJust()"
); } } while (0)
7466 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 3)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7466, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 3)) .FromJust()"
); } } while (0)
;
7467}
7468
7469
7470class NativeFunctionExtension : public Extension {
7471 public:
7472 NativeFunctionExtension(const char* name, const char* source,
7473 v8::FunctionCallback fun = &Echo)
7474 : Extension(name, source), function_(fun) {}
7475
7476 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
7477 v8::Isolate* isolate, v8::Local<v8::String> name) {
7478 return v8::FunctionTemplate::New(isolate, function_);
7479 }
7480
7481 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) {
7482 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]);
7483 }
7484
7485 private:
7486 v8::FunctionCallback function_;
7487};
7488
7489
7490TEST(NativeFunctionDeclaration)static void TestNativeFunctionDeclaration(); CcTest register_test_NativeFunctionDeclaration
(TestNativeFunctionDeclaration, "../test/cctest/test-api.cc",
"NativeFunctionDeclaration", __null, true, true); static void
TestNativeFunctionDeclaration()
{
7491 v8::HandleScope handle_scope(CcTest::isolate());
7492 const char* name = "nativedecl";
7493 v8::RegisterExtension(
7494 new NativeFunctionExtension(name, "native function foo();"));
7495 const char* extension_names[] = {name};
7496 v8::ExtensionConfiguration extensions(1, extension_names);
7497 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7498 Context::Scope lock(context);
7499 v8::Local<Value> result = CompileRun("foo(42);");
7500 CHECK(result->Equals(context, v8::Integer::New(CcTest::isolate(), 42))do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7501, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 42)) .FromJust()"
); } } while (0)
7501 .FromJust())do { if ((__builtin_expect(!!(!(result->Equals(context, v8
::Integer::New(CcTest::isolate(), 42)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7501, "Check failed: %s.", "result->Equals(context, v8::Integer::New(CcTest::isolate(), 42)) .FromJust()"
); } } while (0)
;
7502}
7503
7504
7505TEST(NativeFunctionDeclarationError)static void TestNativeFunctionDeclarationError(); CcTest register_test_NativeFunctionDeclarationError
(TestNativeFunctionDeclarationError, "../test/cctest/test-api.cc"
, "NativeFunctionDeclarationError", __null, true, true); static
void TestNativeFunctionDeclarationError()
{
7506 v8::HandleScope handle_scope(CcTest::isolate());
7507 const char* name = "nativedeclerr";
7508 // Syntax error in extension code.
7509 v8::RegisterExtension(
7510 new NativeFunctionExtension(name, "native\nfunction foo();"));
7511 const char* extension_names[] = {name};
7512 v8::ExtensionConfiguration extensions(1, extension_names);
7513 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7514 CHECK(context.IsEmpty())do { if ((__builtin_expect(!!(!(context.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7514, "Check failed: %s.", "context.IsEmpty()"
); } } while (0)
;
7515}
7516
7517
7518TEST(NativeFunctionDeclarationErrorEscape)static void TestNativeFunctionDeclarationErrorEscape(); CcTest
register_test_NativeFunctionDeclarationErrorEscape(TestNativeFunctionDeclarationErrorEscape
, "../test/cctest/test-api.cc", "NativeFunctionDeclarationErrorEscape"
, __null, true, true); static void TestNativeFunctionDeclarationErrorEscape
()
{
7519 v8::HandleScope handle_scope(CcTest::isolate());
7520 const char* name = "nativedeclerresc";
7521 // Syntax error in extension code - escape code in "native" means that
7522 // it's not treated as a keyword.
7523 v8::RegisterExtension(
7524 new NativeFunctionExtension(name, "nativ\\u0065 function foo();"));
7525 const char* extension_names[] = {name};
7526 v8::ExtensionConfiguration extensions(1, extension_names);
7527 v8::Local<Context> context = Context::New(CcTest::isolate(), &extensions);
7528 CHECK(context.IsEmpty())do { if ((__builtin_expect(!!(!(context.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7528, "Check failed: %s.", "context.IsEmpty()"
); } } while (0)
;
7529}
7530
7531
7532static void CheckDependencies(const char* name, const char* expected) {
7533 v8::HandleScope handle_scope(CcTest::isolate());
7534 v8::ExtensionConfiguration config(1, &name);
7535 LocalContext context(&config);
7536 CHECK(do { if ((__builtin_expect(!!(!(v8_str(expected) ->Equals(
context.local(), context->Global() ->Get(context.local(
), v8_str("loaded")) .ToLocalChecked()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7541, "Check failed: %s."
, "v8_str(expected) ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7537 v8_str(expected)do { if ((__builtin_expect(!!(!(v8_str(expected) ->Equals(
context.local(), context->Global() ->Get(context.local(
), v8_str("loaded")) .ToLocalChecked()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7541, "Check failed: %s."
, "v8_str(expected) ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7538 ->Equals(context.local(), context->Global()do { if ((__builtin_expect(!!(!(v8_str(expected) ->Equals(
context.local(), context->Global() ->Get(context.local(
), v8_str("loaded")) .ToLocalChecked()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7541, "Check failed: %s."
, "v8_str(expected) ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7539 ->Get(context.local(), v8_str("loaded"))do { if ((__builtin_expect(!!(!(v8_str(expected) ->Equals(
context.local(), context->Global() ->Get(context.local(
), v8_str("loaded")) .ToLocalChecked()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7541, "Check failed: %s."
, "v8_str(expected) ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7540 .ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str(expected) ->Equals(
context.local(), context->Global() ->Get(context.local(
), v8_str("loaded")) .ToLocalChecked()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7541, "Check failed: %s."
, "v8_str(expected) ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7541 .FromJust())do { if ((__builtin_expect(!!(!(v8_str(expected) ->Equals(
context.local(), context->Global() ->Get(context.local(
), v8_str("loaded")) .ToLocalChecked()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 7541, "Check failed: %s."
, "v8_str(expected) ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
7542}
7543
7544
7545/*
7546 * Configuration:
7547 *
7548 * /-- B <--\
7549 * A <- -- D <-- E
7550 * \-- C <--/
7551 */
7552THREADED_TEST(ExtensionDependency)static void TestExtensionDependency(); RegisterThreadedTest register_ExtensionDependency
(TestExtensionDependency, "ExtensionDependency"); static void
TestExtensionDependency(); CcTest register_test_ExtensionDependency
(TestExtensionDependency, "../test/cctest/test-api.cc", "ExtensionDependency"
, __null, true, true); static void TestExtensionDependency()
{
7553 static const char* kEDeps[] = {"D"};
7554 v8::RegisterExtension(new Extension("E", "this.loaded += 'E';", 1, kEDeps));
7555 static const char* kDDeps[] = {"B", "C"};
7556 v8::RegisterExtension(new Extension("D", "this.loaded += 'D';", 2, kDDeps));
7557 static const char* kBCDeps[] = {"A"};
7558 v8::RegisterExtension(new Extension("B", "this.loaded += 'B';", 1, kBCDeps));
7559 v8::RegisterExtension(new Extension("C", "this.loaded += 'C';", 1, kBCDeps));
7560 v8::RegisterExtension(new Extension("A", "this.loaded += 'A';"));
7561 CheckDependencies("A", "undefinedA");
7562 CheckDependencies("B", "undefinedAB");
7563 CheckDependencies("C", "undefinedAC");
7564 CheckDependencies("D", "undefinedABCD");
7565 CheckDependencies("E", "undefinedABCDE");
7566 v8::HandleScope handle_scope(CcTest::isolate());
7567 static const char* exts[2] = {"C", "E"};
7568 v8::ExtensionConfiguration config(2, exts);
7569 LocalContext context(&config);
7570 CHECK(do { if ((__builtin_expect(!!(!(v8_str("undefinedACBDE") ->
Equals(context.local(), context->Global() ->Get(context
.local(), v8_str("loaded")) .ToLocalChecked()) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 7575, "Check failed: %s."
, "v8_str(\"undefinedACBDE\") ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7571 v8_str("undefinedACBDE")do { if ((__builtin_expect(!!(!(v8_str("undefinedACBDE") ->
Equals(context.local(), context->Global() ->Get(context
.local(), v8_str("loaded")) .ToLocalChecked()) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 7575, "Check failed: %s."
, "v8_str(\"undefinedACBDE\") ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7572 ->Equals(context.local(), context->Global()do { if ((__builtin_expect(!!(!(v8_str("undefinedACBDE") ->
Equals(context.local(), context->Global() ->Get(context
.local(), v8_str("loaded")) .ToLocalChecked()) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 7575, "Check failed: %s."
, "v8_str(\"undefinedACBDE\") ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7573 ->Get(context.local(), v8_str("loaded"))do { if ((__builtin_expect(!!(!(v8_str("undefinedACBDE") ->
Equals(context.local(), context->Global() ->Get(context
.local(), v8_str("loaded")) .ToLocalChecked()) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 7575, "Check failed: %s."
, "v8_str(\"undefinedACBDE\") ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7574 .ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("undefinedACBDE") ->
Equals(context.local(), context->Global() ->Get(context
.local(), v8_str("loaded")) .ToLocalChecked()) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 7575, "Check failed: %s."
, "v8_str(\"undefinedACBDE\") ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
7575 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("undefinedACBDE") ->
Equals(context.local(), context->Global() ->Get(context
.local(), v8_str("loaded")) .ToLocalChecked()) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 7575, "Check failed: %s."
, "v8_str(\"undefinedACBDE\") ->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"loaded\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
7576}
7577
7578
7579static const char* kExtensionTestScript =
7580 "native function A();"
7581 "native function B();"
7582 "native function C();"
7583 "function Foo(i) {"
7584 " if (i == 0) return A();"
7585 " if (i == 1) return B();"
7586 " if (i == 2) return C();"
7587 "}";
7588
7589
7590static void CallFun(const v8::FunctionCallbackInfo<v8::Value>& args) {
7591 ApiTestFuzzer::Fuzz();
7592 if (args.IsConstructCall()) {
7593 CHECK(args.This()do { if ((__builtin_expect(!!(!(args.This() ->Set(args.GetIsolate
()->GetCurrentContext(), v8_str("data"), args.Data()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7596, "Check failed: %s."
, "args.This() ->Set(args.GetIsolate()->GetCurrentContext(), v8_str(\"data\"), args.Data()) .FromJust()"
); } } while (0)
7594 ->Set(args.GetIsolate()->GetCurrentContext(), v8_str("data"),do { if ((__builtin_expect(!!(!(args.This() ->Set(args.GetIsolate
()->GetCurrentContext(), v8_str("data"), args.Data()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7596, "Check failed: %s."
, "args.This() ->Set(args.GetIsolate()->GetCurrentContext(), v8_str(\"data\"), args.Data()) .FromJust()"
); } } while (0)
7595 args.Data())do { if ((__builtin_expect(!!(!(args.This() ->Set(args.GetIsolate
()->GetCurrentContext(), v8_str("data"), args.Data()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7596, "Check failed: %s."
, "args.This() ->Set(args.GetIsolate()->GetCurrentContext(), v8_str(\"data\"), args.Data()) .FromJust()"
); } } while (0)
7596 .FromJust())do { if ((__builtin_expect(!!(!(args.This() ->Set(args.GetIsolate
()->GetCurrentContext(), v8_str("data"), args.Data()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7596, "Check failed: %s."
, "args.This() ->Set(args.GetIsolate()->GetCurrentContext(), v8_str(\"data\"), args.Data()) .FromJust()"
); } } while (0)
;
7597 args.GetReturnValue().SetNull();
7598 return;
7599 }
7600 args.GetReturnValue().Set(args.Data());
7601}
7602
7603
7604class FunctionExtension : public Extension {
7605 public:
7606 FunctionExtension() : Extension("functiontest", kExtensionTestScript) {}
7607 virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
7608 v8::Isolate* isolate, v8::Local<String> name);
7609};
7610
7611
7612static int lookup_count = 0;
7613v8::Local<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate(
7614 v8::Isolate* isolate, v8::Local<String> name) {
7615 lookup_count++;
7616 if (name->Equals(isolate->GetCurrentContext(), v8_str("A")).FromJust()) {
7617 return v8::FunctionTemplate::New(isolate, CallFun,
7618 v8::Integer::New(isolate, 8));
7619 } else if (name->Equals(isolate->GetCurrentContext(), v8_str("B"))
7620 .FromJust()) {
7621 return v8::FunctionTemplate::New(isolate, CallFun,
7622 v8::Integer::New(isolate, 7));
7623 } else if (name->Equals(isolate->GetCurrentContext(), v8_str("C"))
7624 .FromJust()) {
7625 return v8::FunctionTemplate::New(isolate, CallFun,
7626 v8::Integer::New(isolate, 6));
7627 } else {
7628 return v8::Local<v8::FunctionTemplate>();
7629 }
7630}
7631
7632
7633THREADED_TEST(FunctionLookup)static void TestFunctionLookup(); RegisterThreadedTest register_FunctionLookup
(TestFunctionLookup, "FunctionLookup"); static void TestFunctionLookup
(); CcTest register_test_FunctionLookup(TestFunctionLookup, "../test/cctest/test-api.cc"
, "FunctionLookup", __null, true, true); static void TestFunctionLookup
()
{
7634 v8::RegisterExtension(new FunctionExtension());
7635 v8::HandleScope handle_scope(CcTest::isolate());
7636 static const char* exts[1] = {"functiontest"};
7637 v8::ExtensionConfiguration config(1, exts);
7638 LocalContext context(&config);
7639 CHECK_EQ(3, lookup_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (lookup_count
), "3" " " "==" " " "lookup_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 7639, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
7640 CHECK(v8::Integer::New(CcTest::isolate(), 8)do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 8) ->Equals(context.local(), CompileRun("Foo(0)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7642, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 8) ->Equals(context.local(), CompileRun(\"Foo(0)\")) .FromJust()"
); } } while (0)
7641 ->Equals(context.local(), CompileRun("Foo(0)"))do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 8) ->Equals(context.local(), CompileRun("Foo(0)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7642, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 8) ->Equals(context.local(), CompileRun(\"Foo(0)\")) .FromJust()"
); } } while (0)
7642 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 8) ->Equals(context.local(), CompileRun("Foo(0)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7642, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 8) ->Equals(context.local(), CompileRun(\"Foo(0)\")) .FromJust()"
); } } while (0)
;
7643 CHECK(v8::Integer::New(CcTest::isolate(), 7)do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 7) ->Equals(context.local(), CompileRun("Foo(1)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7645, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 7) ->Equals(context.local(), CompileRun(\"Foo(1)\")) .FromJust()"
); } } while (0)
7644 ->Equals(context.local(), CompileRun("Foo(1)"))do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 7) ->Equals(context.local(), CompileRun("Foo(1)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7645, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 7) ->Equals(context.local(), CompileRun(\"Foo(1)\")) .FromJust()"
); } } while (0)
7645 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 7) ->Equals(context.local(), CompileRun("Foo(1)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7645, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 7) ->Equals(context.local(), CompileRun(\"Foo(1)\")) .FromJust()"
); } } while (0)
;
7646 CHECK(v8::Integer::New(CcTest::isolate(), 6)do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 6) ->Equals(context.local(), CompileRun("Foo(2)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7648, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 6) ->Equals(context.local(), CompileRun(\"Foo(2)\")) .FromJust()"
); } } while (0)
7647 ->Equals(context.local(), CompileRun("Foo(2)"))do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 6) ->Equals(context.local(), CompileRun("Foo(2)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7648, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 6) ->Equals(context.local(), CompileRun(\"Foo(2)\")) .FromJust()"
); } } while (0)
7648 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 6) ->Equals(context.local(), CompileRun("Foo(2)")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7648, "Check failed: %s."
, "v8::Integer::New(CcTest::isolate(), 6) ->Equals(context.local(), CompileRun(\"Foo(2)\")) .FromJust()"
); } } while (0)
;
7649}
7650
7651
7652THREADED_TEST(NativeFunctionConstructCall)static void TestNativeFunctionConstructCall(); RegisterThreadedTest
register_NativeFunctionConstructCall(TestNativeFunctionConstructCall
, "NativeFunctionConstructCall"); static void TestNativeFunctionConstructCall
(); CcTest register_test_NativeFunctionConstructCall(TestNativeFunctionConstructCall
, "../test/cctest/test-api.cc", "NativeFunctionConstructCall"
, __null, true, true); static void TestNativeFunctionConstructCall
()
{
7653 v8::RegisterExtension(new FunctionExtension());
7654 v8::HandleScope handle_scope(CcTest::isolate());
7655 static const char* exts[1] = {"functiontest"};
7656 v8::ExtensionConfiguration config(1, exts);
7657 LocalContext context(&config);
7658 for (int i = 0; i < 10; i++) {
7659 // Run a few times to ensure that allocation of objects doesn't
7660 // change behavior of a constructor function.
7661 CHECK(v8::Integer::New(CcTest::isolate(), 8)do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 8) ->Equals(context.local(), CompileRun("(new A()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7663, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 8) ->Equals(context.local(), CompileRun(\"(new A()).data\")) .FromJust()"
); } } while (0)
7662 ->Equals(context.local(), CompileRun("(new A()).data"))do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 8) ->Equals(context.local(), CompileRun("(new A()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7663, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 8) ->Equals(context.local(), CompileRun(\"(new A()).data\")) .FromJust()"
); } } while (0)
7663 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 8) ->Equals(context.local(), CompileRun("(new A()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7663, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 8) ->Equals(context.local(), CompileRun(\"(new A()).data\")) .FromJust()"
); } } while (0)
;
7664 CHECK(v8::Integer::New(CcTest::isolate(), 7)do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 7) ->Equals(context.local(), CompileRun("(new B()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7666, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 7) ->Equals(context.local(), CompileRun(\"(new B()).data\")) .FromJust()"
); } } while (0)
7665 ->Equals(context.local(), CompileRun("(new B()).data"))do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 7) ->Equals(context.local(), CompileRun("(new B()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7666, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 7) ->Equals(context.local(), CompileRun(\"(new B()).data\")) .FromJust()"
); } } while (0)
7666 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 7) ->Equals(context.local(), CompileRun("(new B()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7666, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 7) ->Equals(context.local(), CompileRun(\"(new B()).data\")) .FromJust()"
); } } while (0)
;
7667 CHECK(v8::Integer::New(CcTest::isolate(), 6)do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 6) ->Equals(context.local(), CompileRun("(new C()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7669, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 6) ->Equals(context.local(), CompileRun(\"(new C()).data\")) .FromJust()"
); } } while (0)
7668 ->Equals(context.local(), CompileRun("(new C()).data"))do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 6) ->Equals(context.local(), CompileRun("(new C()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7669, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 6) ->Equals(context.local(), CompileRun(\"(new C()).data\")) .FromJust()"
); } } while (0)
7669 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(CcTest::isolate
(), 6) ->Equals(context.local(), CompileRun("(new C()).data"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7669, "Check failed: %s.", "v8::Integer::New(CcTest::isolate(), 6) ->Equals(context.local(), CompileRun(\"(new C()).data\")) .FromJust()"
); } } while (0)
;
7670 }
7671}
7672
7673
7674static const char* last_location;
7675static const char* last_message;
7676void StoringErrorCallback(const char* location, const char* message) {
7677 if (last_location == NULL__null) {
7678 last_location = location;
7679 last_message = message;
7680 }
7681}
7682
7683
7684// ErrorReporting creates a circular extensions configuration and
7685// tests that the fatal error handler gets called. This renders V8
7686// unusable and therefore this test cannot be run in parallel.
7687TEST(ErrorReporting)static void TestErrorReporting(); CcTest register_test_ErrorReporting
(TestErrorReporting, "../test/cctest/test-api.cc", "ErrorReporting"
, __null, true, true); static void TestErrorReporting()
{
7688 CcTest::isolate()->SetFatalErrorHandler(StoringErrorCallback);
7689 static const char* aDeps[] = {"B"};
7690 v8::RegisterExtension(new Extension("A", "", 1, aDeps));
7691 static const char* bDeps[] = {"A"};
7692 v8::RegisterExtension(new Extension("B", "", 1, bDeps));
7693 last_location = NULL__null;
7694 v8::ExtensionConfiguration config(1, bDeps);
7695 v8::Local<Context> context = Context::New(CcTest::isolate(), &config);
7696 CHECK(context.IsEmpty())do { if ((__builtin_expect(!!(!(context.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7696, "Check failed: %s.", "context.IsEmpty()"
); } } while (0)
;
7697 CHECK(last_location)do { if ((__builtin_expect(!!(!(last_location)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7697, "Check failed: %s.", "last_location"
); } } while (0)
;
7698}
7699
7700
7701static void MissingScriptInfoMessageListener(v8::Local<v8::Message> message,
7702 v8::Local<Value> data) {
7703 v8::Isolate* isolate = CcTest::isolate();
7704 Local<Context> context = isolate->GetCurrentContext();
7705 CHECK(message->GetScriptOrigin().ResourceName()->IsUndefined())do { if ((__builtin_expect(!!(!(message->GetScriptOrigin()
.ResourceName()->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7705, "Check failed: %s.", "message->GetScriptOrigin().ResourceName()->IsUndefined()"
); } } while (0)
;
7706 CHECK(v8::Undefined(isolate)do { if ((__builtin_expect(!!(!(v8::Undefined(isolate) ->Equals
(context, message->GetScriptOrigin().ResourceName()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7708, "Check failed: %s."
, "v8::Undefined(isolate) ->Equals(context, message->GetScriptOrigin().ResourceName()) .FromJust()"
); } } while (0)
7707 ->Equals(context, message->GetScriptOrigin().ResourceName())do { if ((__builtin_expect(!!(!(v8::Undefined(isolate) ->Equals
(context, message->GetScriptOrigin().ResourceName()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7708, "Check failed: %s."
, "v8::Undefined(isolate) ->Equals(context, message->GetScriptOrigin().ResourceName()) .FromJust()"
); } } while (0)
7708 .FromJust())do { if ((__builtin_expect(!!(!(v8::Undefined(isolate) ->Equals
(context, message->GetScriptOrigin().ResourceName()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7708, "Check failed: %s."
, "v8::Undefined(isolate) ->Equals(context, message->GetScriptOrigin().ResourceName()) .FromJust()"
); } } while (0)
;
7709 message->GetLineNumber(context).FromJust();
7710 message->GetSourceLine(context).ToLocalChecked();
7711}
7712
7713
7714THREADED_TEST(ErrorWithMissingScriptInfo)static void TestErrorWithMissingScriptInfo(); RegisterThreadedTest
register_ErrorWithMissingScriptInfo(TestErrorWithMissingScriptInfo
, "ErrorWithMissingScriptInfo"); static void TestErrorWithMissingScriptInfo
(); CcTest register_test_ErrorWithMissingScriptInfo(TestErrorWithMissingScriptInfo
, "../test/cctest/test-api.cc", "ErrorWithMissingScriptInfo",
__null, true, true); static void TestErrorWithMissingScriptInfo
()
{
7715 LocalContext context;
7716 v8::HandleScope scope(context->GetIsolate());
7717 context->GetIsolate()->AddMessageListener(MissingScriptInfoMessageListener);
7718 CompileRun("throw Error()");
7719 context->GetIsolate()->RemoveMessageListeners(
7720 MissingScriptInfoMessageListener);
7721}
7722
7723
7724struct FlagAndPersistent {
7725 bool flag;
7726 v8::Global<v8::Object> handle;
7727};
7728
7729
7730static void SetFlag(const v8::WeakCallbackInfo<FlagAndPersistent>& data) {
7731 data.GetParameter()->flag = true;
7732 data.GetParameter()->handle.Reset();
7733}
7734
7735
7736static void IndependentWeakHandle(bool global_gc, bool interlinked) {
7737 v8::Isolate* iso = CcTest::isolate();
7738 v8::HandleScope scope(iso);
7739 v8::Local<Context> context = Context::New(iso);
7740 Context::Scope context_scope(context);
7741
7742 FlagAndPersistent object_a, object_b;
7743
7744 intptr_t big_heap_size;
7745
7746 {
7747 v8::HandleScope handle_scope(iso);
7748 Local<Object> a(v8::Object::New(iso));
7749 Local<Object> b(v8::Object::New(iso));
7750 object_a.handle.Reset(iso, a);
7751 object_b.handle.Reset(iso, b);
7752 if (interlinked) {
7753 a->Set(context, v8_str("x"), b).FromJust();
7754 b->Set(context, v8_str("x"), a).FromJust();
7755 }
7756 if (global_gc) {
7757 CcTest::heap()->CollectAllGarbage();
7758 } else {
7759 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
7760 }
7761 // We are relying on this creating a big flag array and reserving the space
7762 // up front.
7763 v8::Local<Value> big_array = CompileRun("new Array(5000)");
7764 a->Set(context, v8_str("y"), big_array).FromJust();
7765 big_heap_size = CcTest::heap()->SizeOfObjects();
7766 }
7767
7768 object_a.flag = false;
7769 object_b.flag = false;
7770 object_a.handle.SetWeak(&object_a, &SetFlag,
7771 v8::WeakCallbackType::kParameter);
7772 object_b.handle.SetWeak(&object_b, &SetFlag,
7773 v8::WeakCallbackType::kParameter);
7774 CHECK(!object_b.handle.IsIndependent())do { if ((__builtin_expect(!!(!(!object_b.handle.IsIndependent
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7774, "Check failed: %s."
, "!object_b.handle.IsIndependent()"); } } while (0)
;
7775 object_a.handle.MarkIndependent();
7776 object_b.handle.MarkIndependent();
7777 CHECK(object_b.handle.IsIndependent())do { if ((__builtin_expect(!!(!(object_b.handle.IsIndependent
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7777, "Check failed: %s."
, "object_b.handle.IsIndependent()"); } } while (0)
;
7778 if (global_gc) {
7779 CcTest::heap()->CollectAllGarbage();
7780 } else {
7781 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
7782 }
7783 // A single GC should be enough to reclaim the memory, since we are using
7784 // phantom handles.
7785 CHECK_LT(CcTest::heap()->SizeOfObjects(), big_heap_size - 20000)do { if (std::string* _msg = ::v8::base::CheckLTImpl( (CcTest
::heap()->SizeOfObjects()), (big_heap_size - 20000), "CcTest::heap()->SizeOfObjects()"
" " "<" " " "big_heap_size - 20000")) { V8_Fatal("../test/cctest/test-api.cc"
, 7785, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
7786 CHECK(object_a.flag)do { if ((__builtin_expect(!!(!(object_a.flag)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7786, "Check failed: %s.", "object_a.flag"
); } } while (0)
;
7787 CHECK(object_b.flag)do { if ((__builtin_expect(!!(!(object_b.flag)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7787, "Check failed: %s.", "object_b.flag"
); } } while (0)
;
7788}
7789
7790
7791TEST(IndependentWeakHandle)static void TestIndependentWeakHandle(); CcTest register_test_IndependentWeakHandle
(TestIndependentWeakHandle, "../test/cctest/test-api.cc", "IndependentWeakHandle"
, __null, true, true); static void TestIndependentWeakHandle(
)
{
7792 IndependentWeakHandle(false, false);
7793 IndependentWeakHandle(false, true);
7794 IndependentWeakHandle(true, false);
7795 IndependentWeakHandle(true, true);
7796}
7797
7798
7799class Trivial {
7800 public:
7801 explicit Trivial(int x) : x_(x) {}
7802
7803 int x() { return x_; }
7804 void set_x(int x) { x_ = x; }
7805
7806 private:
7807 int x_;
7808};
7809
7810
7811class Trivial2 {
7812 public:
7813 Trivial2(int x, int y) : y_(y), x_(x) {}
7814
7815 int x() { return x_; }
7816 void set_x(int x) { x_ = x; }
7817
7818 int y() { return y_; }
7819 void set_y(int y) { y_ = y; }
7820
7821 private:
7822 int y_;
7823 int x_;
7824};
7825
7826
7827void CheckInternalFields(
7828 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
7829 v8::Persistent<v8::Object>* handle = data.GetParameter();
7830 handle->Reset();
7831 Trivial* t1 = reinterpret_cast<Trivial*>(data.GetInternalField(0));
7832 Trivial2* t2 = reinterpret_cast<Trivial2*>(data.GetInternalField(1));
7833 CHECK_EQ(42, t1->x())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
t1->x()), "42" " " "==" " " "t1->x()")) { V8_Fatal("../test/cctest/test-api.cc"
, 7833, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
7834 CHECK_EQ(103, t2->x())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (103), (
t2->x()), "103" " " "==" " " "t2->x()")) { V8_Fatal("../test/cctest/test-api.cc"
, 7834, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
7835 t1->set_x(1729);
7836 t2->set_x(33550336);
7837}
7838
7839
7840void InternalFieldCallback(bool global_gc) {
7841 LocalContext env;
7842 v8::Isolate* isolate = env->GetIsolate();
7843 v8::HandleScope scope(isolate);
7844
7845 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
7846 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
7847 Trivial* t1;
7848 Trivial2* t2;
7849 instance_templ->SetInternalFieldCount(2);
7850 {
7851 v8::HandleScope scope(isolate);
7852 Local<v8::Object> obj = templ->GetFunction(env.local())
7853 .ToLocalChecked()
7854 ->NewInstance(env.local())
7855 .ToLocalChecked();
7856 v8::Persistent<v8::Object> handle(isolate, obj);
7857 CHECK_EQ(2, obj->InternalFieldCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (obj
->InternalFieldCount()), "2" " " "==" " " "obj->InternalFieldCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 7857, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
7858 CHECK(obj->GetInternalField(0)->IsUndefined())do { if ((__builtin_expect(!!(!(obj->GetInternalField(0)->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 7858, "Check failed: %s.", "obj->GetInternalField(0)->IsUndefined()"
); } } while (0)
;
7859 t1 = new Trivial(42);
7860 t2 = new Trivial2(103, 9);
7861
7862 obj->SetAlignedPointerInInternalField(0, t1);
7863 t1 = reinterpret_cast<Trivial*>(obj->GetAlignedPointerFromInternalField(0));
7864 CHECK_EQ(42, t1->x())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
t1->x()), "42" " " "==" " " "t1->x()")) { V8_Fatal("../test/cctest/test-api.cc"
, 7864, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
7865
7866 obj->SetAlignedPointerInInternalField(1, t2);
7867 t2 =
7868 reinterpret_cast<Trivial2*>(obj->GetAlignedPointerFromInternalField(1));
7869 CHECK_EQ(103, t2->x())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (103), (
t2->x()), "103" " " "==" " " "t2->x()")) { V8_Fatal("../test/cctest/test-api.cc"
, 7869, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
7870
7871 handle.SetWeak<v8::Persistent<v8::Object>>(
7872 &handle, CheckInternalFields, v8::WeakCallbackType::kInternalFields);
7873 if (!global_gc) {
7874 handle.MarkIndependent();
7875 }
7876 }
7877 if (global_gc) {
7878 CcTest::heap()->CollectAllGarbage();
7879 } else {
7880 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
7881 }
7882
7883 CHECK_EQ(1729, t1->x())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1729),
(t1->x()), "1729" " " "==" " " "t1->x()")) { V8_Fatal(
"../test/cctest/test-api.cc", 7883, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
7884 CHECK_EQ(33550336, t2->x())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (33550336
), (t2->x()), "33550336" " " "==" " " "t2->x()")) { V8_Fatal
("../test/cctest/test-api.cc", 7884, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
7885
7886 delete t1;
7887 delete t2;
7888}
7889
7890
7891THREADED_TEST(InternalFieldCallback)static void TestInternalFieldCallback(); RegisterThreadedTest
register_InternalFieldCallback(TestInternalFieldCallback, "InternalFieldCallback"
); static void TestInternalFieldCallback(); CcTest register_test_InternalFieldCallback
(TestInternalFieldCallback, "../test/cctest/test-api.cc", "InternalFieldCallback"
, __null, true, true); static void TestInternalFieldCallback(
)
{
7892 InternalFieldCallback(false);
7893 InternalFieldCallback(true);
7894}
7895
7896
7897static void ResetUseValueAndSetFlag(
7898 const v8::WeakCallbackInfo<FlagAndPersistent>& data) {
7899 // Blink will reset the handle, and then use the other handle, so they
7900 // can't use the same backing slot.
7901 data.GetParameter()->handle.Reset();
7902 data.GetParameter()->flag = true;
7903}
7904
7905
7906void v8::internal::HeapTester::ResetWeakHandle(bool global_gc) {
7907 using v8::Context;
7908 using v8::Local;
7909 using v8::Object;
7910
7911 v8::Isolate* iso = CcTest::isolate();
7912 v8::HandleScope scope(iso);
7913 v8::Local<Context> context = Context::New(iso);
7914 Context::Scope context_scope(context);
7915
7916 FlagAndPersistent object_a, object_b;
7917
7918 {
7919 v8::HandleScope handle_scope(iso);
7920 Local<Object> a(v8::Object::New(iso));
7921 Local<Object> b(v8::Object::New(iso));
7922 object_a.handle.Reset(iso, a);
7923 object_b.handle.Reset(iso, b);
7924 if (global_gc) {
7925 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
7926 } else {
7927 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
7928 }
7929 }
7930
7931 object_a.flag = false;
7932 object_b.flag = false;
7933 object_a.handle.SetWeak(&object_a, &ResetUseValueAndSetFlag,
7934 v8::WeakCallbackType::kParameter);
7935 object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag,
7936 v8::WeakCallbackType::kParameter);
7937 if (!global_gc) {
7938 object_a.handle.MarkIndependent();
7939 object_b.handle.MarkIndependent();
7940 CHECK(object_b.handle.IsIndependent())do { if ((__builtin_expect(!!(!(object_b.handle.IsIndependent
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 7940, "Check failed: %s."
, "object_b.handle.IsIndependent()"); } } while (0)
;
7941 }
7942 if (global_gc) {
7943 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
7944 } else {
7945 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
7946 }
7947 CHECK(object_a.flag)do { if ((__builtin_expect(!!(!(object_a.flag)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7947, "Check failed: %s.", "object_a.flag"
); } } while (0)
;
7948 CHECK(object_b.flag)do { if ((__builtin_expect(!!(!(object_b.flag)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 7948, "Check failed: %s.", "object_b.flag"
); } } while (0)
;
7949}
7950
7951
7952THREADED_HEAP_TEST(ResetWeakHandle)RegisterThreadedTest register_ResetWeakHandle(v8::internal::HeapTester
::TestResetWeakHandle, "ResetWeakHandle"); CcTest register_test_ResetWeakHandle
(v8::internal::HeapTester::TestResetWeakHandle, "../test/cctest/test-api.cc"
, "ResetWeakHandle", __null, true, true); void v8::internal::
HeapTester::TestResetWeakHandle()
{
7953 v8::internal::HeapTester::ResetWeakHandle(false);
7954 v8::internal::HeapTester::ResetWeakHandle(true);
7955}
7956
7957
7958static void InvokeScavenge() { CcTest::heap()->CollectGarbage(i::NEW_SPACE); }
7959
7960
7961static void InvokeMarkSweep() { CcTest::heap()->CollectAllGarbage(); }
7962
7963
7964static void ForceScavenge2(
7965 const v8::WeakCallbackInfo<FlagAndPersistent>& data) {
7966 data.GetParameter()->flag = true;
7967 InvokeScavenge();
7968}
7969
7970static void ForceScavenge1(
7971 const v8::WeakCallbackInfo<FlagAndPersistent>& data) {
7972 data.GetParameter()->handle.Reset();
7973 data.SetSecondPassCallback(ForceScavenge2);
7974}
7975
7976
7977static void ForceMarkSweep2(
7978 const v8::WeakCallbackInfo<FlagAndPersistent>& data) {
7979 data.GetParameter()->flag = true;
7980 InvokeMarkSweep();
7981}
7982
7983static void ForceMarkSweep1(
7984 const v8::WeakCallbackInfo<FlagAndPersistent>& data) {
7985 data.GetParameter()->handle.Reset();
7986 data.SetSecondPassCallback(ForceMarkSweep2);
7987}
7988
7989
7990THREADED_TEST(GCFromWeakCallbacks)static void TestGCFromWeakCallbacks(); RegisterThreadedTest register_GCFromWeakCallbacks
(TestGCFromWeakCallbacks, "GCFromWeakCallbacks"); static void
TestGCFromWeakCallbacks(); CcTest register_test_GCFromWeakCallbacks
(TestGCFromWeakCallbacks, "../test/cctest/test-api.cc", "GCFromWeakCallbacks"
, __null, true, true); static void TestGCFromWeakCallbacks()
{
7991 v8::Isolate* isolate = CcTest::isolate();
7992 v8::Locker locker(CcTest::isolate());
7993 v8::HandleScope scope(isolate);
7994 v8::Local<Context> context = Context::New(isolate);
7995 Context::Scope context_scope(context);
7996
7997 static const int kNumberOfGCTypes = 2;
7998 typedef v8::WeakCallbackInfo<FlagAndPersistent>::Callback Callback;
7999 Callback gc_forcing_callback[kNumberOfGCTypes] = {&ForceScavenge1,
8000 &ForceMarkSweep1};
8001
8002 typedef void (*GCInvoker)();
8003 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep};
8004
8005 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) {
8006 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) {
8007 FlagAndPersistent object;
8008 {
8009 v8::HandleScope handle_scope(isolate);
8010 object.handle.Reset(isolate, v8::Object::New(isolate));
8011 }
8012 object.flag = false;
8013 object.handle.SetWeak(&object, gc_forcing_callback[inner_gc],
8014 v8::WeakCallbackType::kParameter);
8015 object.handle.MarkIndependent();
8016 invoke_gc[outer_gc]();
8017 EmptyMessageQueues(isolate);
8018 CHECK(object.flag)do { if ((__builtin_expect(!!(!(object.flag)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8018, "Check failed: %s.", "object.flag"
); } } while (0)
;
8019 }
8020 }
8021}
8022
8023
8024v8::Local<Function> args_fun;
8025
8026
8027static void ArgumentsTestCallback(
8028 const v8::FunctionCallbackInfo<v8::Value>& args) {
8029 ApiTestFuzzer::Fuzz();
8030 v8::Isolate* isolate = args.GetIsolate();
8031 Local<Context> context = isolate->GetCurrentContext();
8032 CHECK_EQ(3, args.Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (args
.Length()), "3" " " "==" " " "args.Length()")) { V8_Fatal("../test/cctest/test-api.cc"
, 8032, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8033 CHECK(v8::Integer::New(isolate, 1)->Equals(context, args[0]).FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 1)->
Equals(context, args[0]).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8033, "Check failed: %s.", "v8::Integer::New(isolate, 1)->Equals(context, args[0]).FromJust()"
); } } while (0)
;
8034 CHECK(v8::Integer::New(isolate, 2)->Equals(context, args[1]).FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 2)->
Equals(context, args[1]).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8034, "Check failed: %s.", "v8::Integer::New(isolate, 2)->Equals(context, args[1]).FromJust()"
); } } while (0)
;
8035 CHECK(v8::Integer::New(isolate, 3)->Equals(context, args[2]).FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 3)->
Equals(context, args[2]).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8035, "Check failed: %s.", "v8::Integer::New(isolate, 3)->Equals(context, args[2]).FromJust()"
); } } while (0)
;
8036 CHECK(v8::Undefined(isolate)->Equals(context, args[3]).FromJust())do { if ((__builtin_expect(!!(!(v8::Undefined(isolate)->Equals
(context, args[3]).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8036, "Check failed: %s.", "v8::Undefined(isolate)->Equals(context, args[3]).FromJust()"
); } } while (0)
;
8037 v8::HandleScope scope(args.GetIsolate());
8038 CcTest::heap()->CollectAllGarbage();
8039}
8040
8041
8042THREADED_TEST(Arguments)static void TestArguments(); RegisterThreadedTest register_Arguments
(TestArguments, "Arguments"); static void TestArguments(); CcTest
register_test_Arguments(TestArguments, "../test/cctest/test-api.cc"
, "Arguments", __null, true, true); static void TestArguments
()
{
8043 v8::Isolate* isolate = CcTest::isolate();
8044 v8::HandleScope scope(isolate);
8045 v8::Local<v8::ObjectTemplate> global = ObjectTemplate::New(isolate);
8046 global->Set(v8_str("f"),
8047 v8::FunctionTemplate::New(isolate, ArgumentsTestCallback));
8048 LocalContext context(NULL__null, global);
8049 args_fun = context->Global()
8050 ->Get(context.local(), v8_str("f"))
8051 .ToLocalChecked()
8052 .As<Function>();
8053 v8_compile("f(1, 2, 3)")->Run(context.local()).ToLocalChecked();
8054}
8055
8056
8057static int p_getter_count;
8058static int p_getter_count2;
8059
8060
8061static void PGetter(Local<Name> name,
8062 const v8::PropertyCallbackInfo<v8::Value>& info) {
8063 ApiTestFuzzer::Fuzz();
8064 p_getter_count++;
8065 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
8066 v8::Local<v8::Object> global = context->Global();
8067 CHECK(do { if ((__builtin_expect(!!(!(info.Holder() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8070, "Check failed: %s."
, "info.Holder() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8068 info.Holder()do { if ((__builtin_expect(!!(!(info.Holder() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8070, "Check failed: %s."
, "info.Holder() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8069 ->Equals(context, global->Get(context, v8_str("o1")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.Holder() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8070, "Check failed: %s."
, "info.Holder() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8070 .FromJust())do { if ((__builtin_expect(!!(!(info.Holder() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8070, "Check failed: %s."
, "info.Holder() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8071 if (name->Equals(context, v8_str("p1")).FromJust()) {
8072 CHECK(info.This()do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8075, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8073 ->Equals(context,do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8075, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8074 global->Get(context, v8_str("o1")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8075, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8075 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8075, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8076 } else if (name->Equals(context, v8_str("p2")).FromJust()) {
8077 CHECK(info.This()do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o2")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8080, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o2\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8078 ->Equals(context,do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o2")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8080, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o2\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8079 global->Get(context, v8_str("o2")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o2")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8080, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o2\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8080 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o2")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8080, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o2\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8081 } else if (name->Equals(context, v8_str("p3")).FromJust()) {
8082 CHECK(info.This()do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o3")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8085, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o3\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8083 ->Equals(context,do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o3")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8085, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o3\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8084 global->Get(context, v8_str("o3")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o3")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8085, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o3\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8085 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o3")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8085, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o3\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8086 } else if (name->Equals(context, v8_str("p4")).FromJust()) {
8087 CHECK(info.This()do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o4")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8090, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o4\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8088 ->Equals(context,do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o4")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8090, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o4\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8089 global->Get(context, v8_str("o4")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o4")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8090, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o4\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8090 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o4")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8090, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o4\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8091 }
8092}
8093
8094
8095static void RunHolderTest(v8::Local<v8::ObjectTemplate> obj) {
8096 ApiTestFuzzer::Fuzz();
8097 LocalContext context;
8098 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8101, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
8099 ->Set(context.local(), v8_str("o1"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8101, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
8100 obj->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8101, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
8101 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8101, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8102 CompileRun(
8103 "o1.__proto__ = { };"
8104 "var o2 = { __proto__: o1 };"
8105 "var o3 = { __proto__: o2 };"
8106 "var o4 = { __proto__: o3 };"
8107 "for (var i = 0; i < 10; i++) o4.p4;"
8108 "for (var i = 0; i < 10; i++) o3.p3;"
8109 "for (var i = 0; i < 10; i++) o2.p2;"
8110 "for (var i = 0; i < 10; i++) o1.p1;");
8111}
8112
8113
8114static void PGetter2(Local<Name> name,
8115 const v8::PropertyCallbackInfo<v8::Value>& info) {
8116 ApiTestFuzzer::Fuzz();
8117 p_getter_count2++;
8118 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
8119 v8::Local<v8::Object> global = context->Global();
8120 CHECK(do { if ((__builtin_expect(!!(!(info.Holder() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8123, "Check failed: %s."
, "info.Holder() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8121 info.Holder()do { if ((__builtin_expect(!!(!(info.Holder() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8123, "Check failed: %s."
, "info.Holder() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8122 ->Equals(context, global->Get(context, v8_str("o1")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.Holder() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8123, "Check failed: %s."
, "info.Holder() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8123 .FromJust())do { if ((__builtin_expect(!!(!(info.Holder() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8123, "Check failed: %s."
, "info.Holder() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8124 if (name->Equals(context, v8_str("p1")).FromJust()) {
8125 CHECK(info.This()do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8128, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8126 ->Equals(context,do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8128, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8127 global->Get(context, v8_str("o1")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8128, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8128 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o1")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8128, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8129 } else if (name->Equals(context, v8_str("p2")).FromJust()) {
8130 CHECK(info.This()do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o2")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8133, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o2\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8131 ->Equals(context,do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o2")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8133, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o2\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8132 global->Get(context, v8_str("o2")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o2")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8133, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o2\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8133 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o2")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8133, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o2\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8134 } else if (name->Equals(context, v8_str("p3")).FromJust()) {
8135 CHECK(info.This()do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o3")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8138, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o3\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8136 ->Equals(context,do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o3")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8138, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o3\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8137 global->Get(context, v8_str("o3")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o3")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8138, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o3\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8138 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o3")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8138, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o3\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8139 } else if (name->Equals(context, v8_str("p4")).FromJust()) {
8140 CHECK(info.This()do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o4")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8143, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o4\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8141 ->Equals(context,do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o4")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8143, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o4\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8142 global->Get(context, v8_str("o4")).ToLocalChecked())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o4")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8143, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o4\")).ToLocalChecked()) .FromJust()"
); } } while (0)
8143 .FromJust())do { if ((__builtin_expect(!!(!(info.This() ->Equals(context
, global->Get(context, v8_str("o4")).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8143, "Check failed: %s."
, "info.This() ->Equals(context, global->Get(context, v8_str(\"o4\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8144 }
8145}
8146
8147
8148THREADED_TEST(GetterHolders)static void TestGetterHolders(); RegisterThreadedTest register_GetterHolders
(TestGetterHolders, "GetterHolders"); static void TestGetterHolders
(); CcTest register_test_GetterHolders(TestGetterHolders, "../test/cctest/test-api.cc"
, "GetterHolders", __null, true, true); static void TestGetterHolders
()
{
8149 v8::Isolate* isolate = CcTest::isolate();
8150 v8::HandleScope scope(isolate);
8151 v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
8152 obj->SetAccessor(v8_str("p1"), PGetter);
8153 obj->SetAccessor(v8_str("p2"), PGetter);
8154 obj->SetAccessor(v8_str("p3"), PGetter);
8155 obj->SetAccessor(v8_str("p4"), PGetter);
8156 p_getter_count = 0;
8157 RunHolderTest(obj);
8158 CHECK_EQ(40, p_getter_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
p_getter_count), "40" " " "==" " " "p_getter_count")) { V8_Fatal
("../test/cctest/test-api.cc", 8158, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8159}
8160
8161
8162THREADED_TEST(PreInterceptorHolders)static void TestPreInterceptorHolders(); RegisterThreadedTest
register_PreInterceptorHolders(TestPreInterceptorHolders, "PreInterceptorHolders"
); static void TestPreInterceptorHolders(); CcTest register_test_PreInterceptorHolders
(TestPreInterceptorHolders, "../test/cctest/test-api.cc", "PreInterceptorHolders"
, __null, true, true); static void TestPreInterceptorHolders(
)
{
8163 v8::Isolate* isolate = CcTest::isolate();
8164 v8::HandleScope scope(isolate);
8165 v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
8166 obj->SetHandler(v8::NamedPropertyHandlerConfiguration(PGetter2));
8167 p_getter_count2 = 0;
8168 RunHolderTest(obj);
8169 CHECK_EQ(40, p_getter_count2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
p_getter_count2), "40" " " "==" " " "p_getter_count2")) { V8_Fatal
("../test/cctest/test-api.cc", 8169, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8170}
8171
8172
8173THREADED_TEST(ObjectInstantiation)static void TestObjectInstantiation(); RegisterThreadedTest register_ObjectInstantiation
(TestObjectInstantiation, "ObjectInstantiation"); static void
TestObjectInstantiation(); CcTest register_test_ObjectInstantiation
(TestObjectInstantiation, "../test/cctest/test-api.cc", "ObjectInstantiation"
, __null, true, true); static void TestObjectInstantiation()
{
8174 v8::Isolate* isolate = CcTest::isolate();
8175 v8::HandleScope scope(isolate);
8176 v8::Local<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
8177 templ->SetAccessor(v8_str("t"), PGetter2);
8178 LocalContext context;
8179 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8182, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
8180 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8182, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
8181 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8182, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
8182 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8182, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8183 for (int i = 0; i < 100; i++) {
8184 v8::HandleScope inner_scope(CcTest::isolate());
8185 v8::Local<v8::Object> obj =
8186 templ->NewInstance(context.local()).ToLocalChecked();
8187 CHECK(!obj->Equals(context.local(), context->Global()do { if ((__builtin_expect(!!(!(!obj->Equals(context.local
(), context->Global() ->Get(context.local(), v8_str("o"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8190, "Check failed: %s.", "!obj->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"o\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
8188 ->Get(context.local(), v8_str("o"))do { if ((__builtin_expect(!!(!(!obj->Equals(context.local
(), context->Global() ->Get(context.local(), v8_str("o"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8190, "Check failed: %s.", "!obj->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"o\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
8189 .ToLocalChecked())do { if ((__builtin_expect(!!(!(!obj->Equals(context.local
(), context->Global() ->Get(context.local(), v8_str("o"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8190, "Check failed: %s.", "!obj->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"o\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
8190 .FromJust())do { if ((__builtin_expect(!!(!(!obj->Equals(context.local
(), context->Global() ->Get(context.local(), v8_str("o"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8190, "Check failed: %s.", "!obj->Equals(context.local(), context->Global() ->Get(context.local(), v8_str(\"o\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
8191 CHECK(do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("o2"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8192, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"o2\"), obj).FromJust()"
); } } while (0)
8192 context->Global()->Set(context.local(), v8_str("o2"), obj).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("o2"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8192, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"o2\"), obj).FromJust()"
); } } while (0)
;
8193 v8::Local<Value> value = CompileRun("o.__proto__ === o2.__proto__");
8194 CHECK(v8::True(isolate)->Equals(context.local(), value).FromJust())do { if ((__builtin_expect(!!(!(v8::True(isolate)->Equals(
context.local(), value).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8194, "Check failed: %s.", "v8::True(isolate)->Equals(context.local(), value).FromJust()"
); } } while (0)
;
8195 CHECK(context->Global()->Set(context.local(), v8_str("o"), obj).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("o"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8195, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"o\"), obj).FromJust()"
); } } while (0)
;
8196 }
8197}
8198
8199
8200static int StrCmp16(uint16_t* a, uint16_t* b) {
8201 while (true) {
8202 if (*a == 0 && *b == 0) return 0;
8203 if (*a != *b) return 0 + *a - *b;
8204 a++;
8205 b++;
8206 }
8207}
8208
8209
8210static int StrNCmp16(uint16_t* a, uint16_t* b, int n) {
8211 while (true) {
8212 if (n-- == 0) return 0;
8213 if (*a == 0 && *b == 0) return 0;
8214 if (*a != *b) return 0 + *a - *b;
8215 a++;
8216 b++;
8217 }
8218}
8219
8220
8221int GetUtf8Length(Local<String> str) {
8222 int len = str->Utf8Length();
8223 if (len < 0) {
8224 i::Handle<i::String> istr(v8::Utils::OpenHandle(*str));
8225 i::String::Flatten(istr);
8226 len = str->Utf8Length();
8227 }
8228 return len;
8229}
8230
8231
8232THREADED_TEST(StringWrite)static void TestStringWrite(); RegisterThreadedTest register_StringWrite
(TestStringWrite, "StringWrite"); static void TestStringWrite
(); CcTest register_test_StringWrite(TestStringWrite, "../test/cctest/test-api.cc"
, "StringWrite", __null, true, true); static void TestStringWrite
()
{
8233 LocalContext context;
8234 v8::HandleScope scope(context->GetIsolate());
8235 v8::Local<String> str = v8_str("abcde");
8236 // abc<Icelandic eth><Unicode snowman>.
8237 v8::Local<String> str2 = v8_str("abc\303\260\342\230\203");
8238 v8::Local<String> str3 =
8239 v8::String::NewFromUtf8(context->GetIsolate(), "abc\0def",
8240 v8::NewStringType::kNormal, 7)
8241 .ToLocalChecked();
8242 // "ab" + lead surrogate + "cd" + trail surrogate + "ef"
8243 uint16_t orphans[8] = { 0x61, 0x62, 0xd800, 0x63, 0x64, 0xdc00, 0x65, 0x66 };
8244 v8::Local<String> orphans_str =
8245 v8::String::NewFromTwoByte(context->GetIsolate(), orphans,
8246 v8::NewStringType::kNormal, 8)
8247 .ToLocalChecked();
8248 // single lead surrogate
8249 uint16_t lead[1] = { 0xd800 };
8250 v8::Local<String> lead_str =
8251 v8::String::NewFromTwoByte(context->GetIsolate(), lead,
8252 v8::NewStringType::kNormal, 1)
8253 .ToLocalChecked();
8254 // single trail surrogate
8255 uint16_t trail[1] = { 0xdc00 };
8256 v8::Local<String> trail_str =
8257 v8::String::NewFromTwoByte(context->GetIsolate(), trail,
8258 v8::NewStringType::kNormal, 1)
8259 .ToLocalChecked();
8260 // surrogate pair
8261 uint16_t pair[2] = { 0xd800, 0xdc00 };
8262 v8::Local<String> pair_str =
8263 v8::String::NewFromTwoByte(context->GetIsolate(), pair,
8264 v8::NewStringType::kNormal, 2)
8265 .ToLocalChecked();
8266 const int kStride = 4; // Must match stride in for loops in JS below.
8267 CompileRun(
8268 "var left = '';"
8269 "for (var i = 0; i < 0xd800; i += 4) {"
8270 " left = left + String.fromCharCode(i);"
8271 "}");
8272 CompileRun(
8273 "var right = '';"
8274 "for (var i = 0; i < 0xd800; i += 4) {"
8275 " right = String.fromCharCode(i) + right;"
8276 "}");
8277 v8::Local<v8::Object> global = context->Global();
8278 Local<String> left_tree = global->Get(context.local(), v8_str("left"))
8279 .ToLocalChecked()
8280 .As<String>();
8281 Local<String> right_tree = global->Get(context.local(), v8_str("right"))
8282 .ToLocalChecked()
8283 .As<String>();
8284
8285 CHECK_EQ(5, str2->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (str2
->Length()), "5" " " "==" " " "str2->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 8285, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8286 CHECK_EQ(0xd800 / kStride, left_tree->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xd800
/ kStride), (left_tree->Length()), "0xd800 / kStride" " "
"==" " " "left_tree->Length()")) { V8_Fatal("../test/cctest/test-api.cc"
, 8286, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8287 CHECK_EQ(0xd800 / kStride, right_tree->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xd800
/ kStride), (right_tree->Length()), "0xd800 / kStride" " "
"==" " " "right_tree->Length()")) { V8_Fatal("../test/cctest/test-api.cc"
, 8287, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8288
8289 char buf[100];
8290 char utf8buf[0xd800 * 3];
8291 uint16_t wbuf[100];
8292 int len;
8293 int charlen;
8294
8295 memset(utf8buf, 0x1, 1000);
8296 len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen);
8297 CHECK_EQ(9, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9), (len
), "9" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8297, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8298 CHECK_EQ(5, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (charlen
), "5" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8298, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8299 CHECK_EQ(0, strcmp(utf8buf, "abc\303\260\342\230\203"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(utf8buf, "abc\303\260\342\230\203")), "0" " " "==" " " "strcmp(utf8buf, \"abc\\303\\260\\342\\230\\203\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 8299, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8300
8301 memset(utf8buf, 0x1, 1000);
8302 len = str2->WriteUtf8(utf8buf, 8, &charlen);
8303 CHECK_EQ(8, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (len
), "8" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8303, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8304 CHECK_EQ(5, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (charlen
), "5" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8304, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8305 CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\342\230\203\1", 9))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
(utf8buf, "abc\303\260\342\230\203\1", 9)), "0" " " "==" " " "strncmp(utf8buf, \"abc\\303\\260\\342\\230\\203\\1\", 9)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8305, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8306
8307 memset(utf8buf, 0x1, 1000);
8308 len = str2->WriteUtf8(utf8buf, 7, &charlen);
8309 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8309, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8310 CHECK_EQ(4, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (charlen
), "4" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8310, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8311 CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
(utf8buf, "abc\303\260\1", 5)), "0" " " "==" " " "strncmp(utf8buf, \"abc\\303\\260\\1\", 5)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8311, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8312
8313 memset(utf8buf, 0x1, 1000);
8314 len = str2->WriteUtf8(utf8buf, 6, &charlen);
8315 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8315, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8316 CHECK_EQ(4, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (charlen
), "4" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8316, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8317 CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
(utf8buf, "abc\303\260\1", 5)), "0" " " "==" " " "strncmp(utf8buf, \"abc\\303\\260\\1\", 5)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8317, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8318
8319 memset(utf8buf, 0x1, 1000);
8320 len = str2->WriteUtf8(utf8buf, 5, &charlen);
8321 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8321, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8322 CHECK_EQ(4, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (charlen
), "4" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8322, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8323 CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
(utf8buf, "abc\303\260\1", 5)), "0" " " "==" " " "strncmp(utf8buf, \"abc\\303\\260\\1\", 5)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8323, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8324
8325 memset(utf8buf, 0x1, 1000);
8326 len = str2->WriteUtf8(utf8buf, 4, &charlen);
8327 CHECK_EQ(3, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (len
), "3" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8327, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8328 CHECK_EQ(3, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (charlen
), "3" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8328, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8329 CHECK_EQ(0, strncmp(utf8buf, "abc\1", 4))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
(utf8buf, "abc\1", 4)), "0" " " "==" " " "strncmp(utf8buf, \"abc\\1\", 4)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8329, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8330
8331 memset(utf8buf, 0x1, 1000);
8332 len = str2->WriteUtf8(utf8buf, 3, &charlen);
8333 CHECK_EQ(3, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (len
), "3" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8333, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8334 CHECK_EQ(3, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (charlen
), "3" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8334, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8335 CHECK_EQ(0, strncmp(utf8buf, "abc\1", 4))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
(utf8buf, "abc\1", 4)), "0" " " "==" " " "strncmp(utf8buf, \"abc\\1\", 4)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8335, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8336
8337 memset(utf8buf, 0x1, 1000);
8338 len = str2->WriteUtf8(utf8buf, 2, &charlen);
8339 CHECK_EQ(2, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (len
), "2" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8339, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8340 CHECK_EQ(2, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (charlen
), "2" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8340, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8341 CHECK_EQ(0, strncmp(utf8buf, "ab\1", 3))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
(utf8buf, "ab\1", 3)), "0" " " "==" " " "strncmp(utf8buf, \"ab\\1\", 3)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8341, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8342
8343 // allow orphan surrogates by default
8344 memset(utf8buf, 0x1, 1000);
8345 len = orphans_str->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen);
8346 CHECK_EQ(13, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
len), "13" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8346, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8347 CHECK_EQ(8, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (charlen
), "8" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8347, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8348 CHECK_EQ(0, strcmp(utf8buf, "ab\355\240\200cd\355\260\200ef"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(utf8buf, "ab\355\240\200cd\355\260\200ef")), "0" " " "==" " "
"strcmp(utf8buf, \"ab\\355\\240\\200cd\\355\\260\\200ef\")")
) { V8_Fatal("../test/cctest/test-api.cc", 8348, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8349
8350 // replace orphan surrogates with unicode replacement character
8351 memset(utf8buf, 0x1, 1000);
8352 len = orphans_str->WriteUtf8(utf8buf,
8353 sizeof(utf8buf),
8354 &charlen,
8355 String::REPLACE_INVALID_UTF8);
8356 CHECK_EQ(13, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
len), "13" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8356, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8357 CHECK_EQ(8, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (charlen
), "8" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8357, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8358 CHECK_EQ(0, strcmp(utf8buf, "ab\357\277\275cd\357\277\275ef"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(utf8buf, "ab\357\277\275cd\357\277\275ef")), "0" " " "==" " "
"strcmp(utf8buf, \"ab\\357\\277\\275cd\\357\\277\\275ef\")")
) { V8_Fatal("../test/cctest/test-api.cc", 8358, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8359
8360 // replace single lead surrogate with unicode replacement character
8361 memset(utf8buf, 0x1, 1000);
8362 len = lead_str->WriteUtf8(utf8buf,
8363 sizeof(utf8buf),
8364 &charlen,
8365 String::REPLACE_INVALID_UTF8);
8366 CHECK_EQ(4, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (len
), "4" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8366, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8367 CHECK_EQ(1, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (charlen
), "1" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8367, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8368 CHECK_EQ(0, strcmp(utf8buf, "\357\277\275"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(utf8buf, "\357\277\275")), "0" " " "==" " " "strcmp(utf8buf, \"\\357\\277\\275\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 8368, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8369
8370 // replace single trail surrogate with unicode replacement character
8371 memset(utf8buf, 0x1, 1000);
8372 len = trail_str->WriteUtf8(utf8buf,
8373 sizeof(utf8buf),
8374 &charlen,
8375 String::REPLACE_INVALID_UTF8);
8376 CHECK_EQ(4, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (len
), "4" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8376, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8377 CHECK_EQ(1, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (charlen
), "1" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8377, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8378 CHECK_EQ(0, strcmp(utf8buf, "\357\277\275"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(utf8buf, "\357\277\275")), "0" " " "==" " " "strcmp(utf8buf, \"\\357\\277\\275\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 8378, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8379
8380 // do not replace / write anything if surrogate pair does not fit the buffer
8381 // space
8382 memset(utf8buf, 0x1, 1000);
8383 len = pair_str->WriteUtf8(utf8buf,
8384 3,
8385 &charlen,
8386 String::REPLACE_INVALID_UTF8);
8387 CHECK_EQ(0, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (len
), "0" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8387, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8388 CHECK_EQ(0, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (charlen
), "0" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8388, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8389
8390 memset(utf8buf, 0x1, sizeof(utf8buf));
8391 len = GetUtf8Length(left_tree);
8392 int utf8_expected =
8393 (0x80 + (0x800 - 0x80) * 2 + (0xd800 - 0x800) * 3) / kStride;
8394 CHECK_EQ(utf8_expected, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (utf8_expected
), (len), "utf8_expected" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8394, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8395 len = left_tree->WriteUtf8(utf8buf, utf8_expected, &charlen);
8396 CHECK_EQ(utf8_expected, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (utf8_expected
), (len), "utf8_expected" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8396, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8397 CHECK_EQ(0xd800 / kStride, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xd800
/ kStride), (charlen), "0xd800 / kStride" " " "==" " " "charlen"
)) { V8_Fatal("../test/cctest/test-api.cc", 8397, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8398 CHECK_EQ(0xed, static_cast<unsigned char>(utf8buf[utf8_expected - 3]))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xed),
(static_cast<unsigned char>(utf8buf[utf8_expected - 3]
)), "0xed" " " "==" " " "static_cast<unsigned char>(utf8buf[utf8_expected - 3])"
)) { V8_Fatal("../test/cctest/test-api.cc", 8398, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8399 CHECK_EQ(0x9f, static_cast<unsigned char>(utf8buf[utf8_expected - 2]))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0x9f),
(static_cast<unsigned char>(utf8buf[utf8_expected - 2]
)), "0x9f" " " "==" " " "static_cast<unsigned char>(utf8buf[utf8_expected - 2])"
)) { V8_Fatal("../test/cctest/test-api.cc", 8399, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8400 CHECK_EQ(0xc0 - kStride,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xc0 -
kStride), (static_cast<unsigned char>(utf8buf[utf8_expected
- 1])), "0xc0 - kStride" " " "==" " " "static_cast<unsigned char>(utf8buf[utf8_expected - 1])"
)) { V8_Fatal("../test/cctest/test-api.cc", 8401, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
8401 static_cast<unsigned char>(utf8buf[utf8_expected - 1]))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xc0 -
kStride), (static_cast<unsigned char>(utf8buf[utf8_expected
- 1])), "0xc0 - kStride" " " "==" " " "static_cast<unsigned char>(utf8buf[utf8_expected - 1])"
)) { V8_Fatal("../test/cctest/test-api.cc", 8401, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8402 CHECK_EQ(1, utf8buf[utf8_expected])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (utf8buf
[utf8_expected]), "1" " " "==" " " "utf8buf[utf8_expected]"))
{ V8_Fatal("../test/cctest/test-api.cc", 8402, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8403
8404 memset(utf8buf, 0x1, sizeof(utf8buf));
8405 len = GetUtf8Length(right_tree);
8406 CHECK_EQ(utf8_expected, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (utf8_expected
), (len), "utf8_expected" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8406, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8407 len = right_tree->WriteUtf8(utf8buf, utf8_expected, &charlen);
8408 CHECK_EQ(utf8_expected, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (utf8_expected
), (len), "utf8_expected" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8408, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8409 CHECK_EQ(0xd800 / kStride, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xd800
/ kStride), (charlen), "0xd800 / kStride" " " "==" " " "charlen"
)) { V8_Fatal("../test/cctest/test-api.cc", 8409, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8410 CHECK_EQ(0xed, static_cast<unsigned char>(utf8buf[0]))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xed),
(static_cast<unsigned char>(utf8buf[0])), "0xed" " " "=="
" " "static_cast<unsigned char>(utf8buf[0])")) { V8_Fatal
("../test/cctest/test-api.cc", 8410, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8411 CHECK_EQ(0x9f, static_cast<unsigned char>(utf8buf[1]))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0x9f),
(static_cast<unsigned char>(utf8buf[1])), "0x9f" " " "=="
" " "static_cast<unsigned char>(utf8buf[1])")) { V8_Fatal
("../test/cctest/test-api.cc", 8411, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8412 CHECK_EQ(0xc0 - kStride, static_cast<unsigned char>(utf8buf[2]))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xc0 -
kStride), (static_cast<unsigned char>(utf8buf[2])), "0xc0 - kStride"
" " "==" " " "static_cast<unsigned char>(utf8buf[2])")
) { V8_Fatal("../test/cctest/test-api.cc", 8412, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8413 CHECK_EQ(1, utf8buf[utf8_expected])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (utf8buf
[utf8_expected]), "1" " " "==" " " "utf8buf[utf8_expected]"))
{ V8_Fatal("../test/cctest/test-api.cc", 8413, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8414
8415 memset(buf, 0x1, sizeof(buf));
8416 memset(wbuf, 0x1, sizeof(wbuf));
8417 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf));
8418 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8418, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8419 len = str->Write(wbuf);
8420 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8420, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8421 CHECK_EQ(0, strcmp("abcde", buf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("abcde", buf)), "0" " " "==" " " "strcmp(\"abcde\", buf)")) {
V8_Fatal("../test/cctest/test-api.cc", 8421, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8422 uint16_t answer1[] = {'a', 'b', 'c', 'd', 'e', '\0'};
8423 CHECK_EQ(0, StrCmp16(answer1, wbuf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrCmp16
(answer1, wbuf)), "0" " " "==" " " "StrCmp16(answer1, wbuf)")
) { V8_Fatal("../test/cctest/test-api.cc", 8423, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8424
8425 memset(buf, 0x1, sizeof(buf));
8426 memset(wbuf, 0x1, sizeof(wbuf));
8427 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 4);
8428 CHECK_EQ(4, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (len
), "4" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8428, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8429 len = str->Write(wbuf, 0, 4);
8430 CHECK_EQ(4, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (len
), "4" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8430, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8431 CHECK_EQ(0, strncmp("abcd\1", buf, 5))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
("abcd\1", buf, 5)), "0" " " "==" " " "strncmp(\"abcd\\1\", buf, 5)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8431, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8432 uint16_t answer2[] = {'a', 'b', 'c', 'd', 0x101};
8433 CHECK_EQ(0, StrNCmp16(answer2, wbuf, 5))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrNCmp16
(answer2, wbuf, 5)), "0" " " "==" " " "StrNCmp16(answer2, wbuf, 5)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8433, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8434
8435 memset(buf, 0x1, sizeof(buf));
8436 memset(wbuf, 0x1, sizeof(wbuf));
8437 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 5);
8438 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8438, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8439 len = str->Write(wbuf, 0, 5);
8440 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8440, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8441 CHECK_EQ(0, strncmp("abcde\1", buf, 6))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
("abcde\1", buf, 6)), "0" " " "==" " " "strncmp(\"abcde\\1\", buf, 6)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8441, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8442 uint16_t answer3[] = {'a', 'b', 'c', 'd', 'e', 0x101};
8443 CHECK_EQ(0, StrNCmp16(answer3, wbuf, 6))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrNCmp16
(answer3, wbuf, 6)), "0" " " "==" " " "StrNCmp16(answer3, wbuf, 6)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8443, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8444
8445 memset(buf, 0x1, sizeof(buf));
8446 memset(wbuf, 0x1, sizeof(wbuf));
8447 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 6);
8448 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8448, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8449 len = str->Write(wbuf, 0, 6);
8450 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8450, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8451 CHECK_EQ(0, strcmp("abcde", buf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("abcde", buf)), "0" " " "==" " " "strcmp(\"abcde\", buf)")) {
V8_Fatal("../test/cctest/test-api.cc", 8451, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8452 uint16_t answer4[] = {'a', 'b', 'c', 'd', 'e', '\0'};
8453 CHECK_EQ(0, StrCmp16(answer4, wbuf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrCmp16
(answer4, wbuf)), "0" " " "==" " " "StrCmp16(answer4, wbuf)")
) { V8_Fatal("../test/cctest/test-api.cc", 8453, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8454
8455 memset(buf, 0x1, sizeof(buf));
8456 memset(wbuf, 0x1, sizeof(wbuf));
8457 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, -1);
8458 CHECK_EQ(1, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (len
), "1" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8458, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8459 len = str->Write(wbuf, 4, -1);
8460 CHECK_EQ(1, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (len
), "1" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8460, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8461 CHECK_EQ(0, strcmp("e", buf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("e", buf)), "0" " " "==" " " "strcmp(\"e\", buf)")) { V8_Fatal
("../test/cctest/test-api.cc", 8461, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8462 uint16_t answer5[] = {'e', '\0'};
8463 CHECK_EQ(0, StrCmp16(answer5, wbuf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrCmp16
(answer5, wbuf)), "0" " " "==" " " "StrCmp16(answer5, wbuf)")
) { V8_Fatal("../test/cctest/test-api.cc", 8463, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8464
8465 memset(buf, 0x1, sizeof(buf));
8466 memset(wbuf, 0x1, sizeof(wbuf));
8467 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, 6);
8468 CHECK_EQ(1, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (len
), "1" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8468, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8469 len = str->Write(wbuf, 4, 6);
8470 CHECK_EQ(1, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (len
), "1" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8470, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8471 CHECK_EQ(0, strcmp("e", buf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("e", buf)), "0" " " "==" " " "strcmp(\"e\", buf)")) { V8_Fatal
("../test/cctest/test-api.cc", 8471, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8472 CHECK_EQ(0, StrCmp16(answer5, wbuf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrCmp16
(answer5, wbuf)), "0" " " "==" " " "StrCmp16(answer5, wbuf)")
) { V8_Fatal("../test/cctest/test-api.cc", 8472, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8473
8474 memset(buf, 0x1, sizeof(buf));
8475 memset(wbuf, 0x1, sizeof(wbuf));
8476 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, 1);
8477 CHECK_EQ(1, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (len
), "1" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8477, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8478 len = str->Write(wbuf, 4, 1);
8479 CHECK_EQ(1, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (len
), "1" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8479, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8480 CHECK_EQ(0, strncmp("e\1", buf, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
("e\1", buf, 2)), "0" " " "==" " " "strncmp(\"e\\1\", buf, 2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8480, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8481 uint16_t answer6[] = {'e', 0x101};
8482 CHECK_EQ(0, StrNCmp16(answer6, wbuf, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrNCmp16
(answer6, wbuf, 2)), "0" " " "==" " " "StrNCmp16(answer6, wbuf, 2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8482, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8483
8484 memset(buf, 0x1, sizeof(buf));
8485 memset(wbuf, 0x1, sizeof(wbuf));
8486 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 3, 1);
8487 CHECK_EQ(1, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (len
), "1" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8487, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8488 len = str->Write(wbuf, 3, 1);
8489 CHECK_EQ(1, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (len
), "1" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8489, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8490 CHECK_EQ(0, strncmp("d\1", buf, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
("d\1", buf, 2)), "0" " " "==" " " "strncmp(\"d\\1\", buf, 2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8490, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8491 uint16_t answer7[] = {'d', 0x101};
8492 CHECK_EQ(0, StrNCmp16(answer7, wbuf, 2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrNCmp16
(answer7, wbuf, 2)), "0" " " "==" " " "StrNCmp16(answer7, wbuf, 2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8492, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8493
8494 memset(wbuf, 0x1, sizeof(wbuf));
8495 wbuf[5] = 'X';
8496 len = str->Write(wbuf, 0, 6, String::NO_NULL_TERMINATION);
8497 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8497, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8498 CHECK_EQ('X', wbuf[5])do { if (std::string* _msg = ::v8::base::CheckEQImpl( ('X'), (
wbuf[5]), "'X'" " " "==" " " "wbuf[5]")) { V8_Fatal("../test/cctest/test-api.cc"
, 8498, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8499 uint16_t answer8a[] = {'a', 'b', 'c', 'd', 'e'};
8500 uint16_t answer8b[] = {'a', 'b', 'c', 'd', 'e', '\0'};
8501 CHECK_EQ(0, StrNCmp16(answer8a, wbuf, 5))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrNCmp16
(answer8a, wbuf, 5)), "0" " " "==" " " "StrNCmp16(answer8a, wbuf, 5)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8501, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8502 CHECK_NE(0, StrCmp16(answer8b, wbuf))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (0), (StrCmp16
(answer8b, wbuf)), "0" " " "!=" " " "StrCmp16(answer8b, wbuf)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8502, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8503 wbuf[5] = '\0';
8504 CHECK_EQ(0, StrCmp16(answer8b, wbuf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (StrCmp16
(answer8b, wbuf)), "0" " " "==" " " "StrCmp16(answer8b, wbuf)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8504, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8505
8506 memset(buf, 0x1, sizeof(buf));
8507 buf[5] = 'X';
8508 len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf),
8509 0,
8510 6,
8511 String::NO_NULL_TERMINATION);
8512 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8512, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8513 CHECK_EQ('X', buf[5])do { if (std::string* _msg = ::v8::base::CheckEQImpl( ('X'), (
buf[5]), "'X'" " " "==" " " "buf[5]")) { V8_Fatal("../test/cctest/test-api.cc"
, 8513, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8514 CHECK_EQ(0, strncmp("abcde", buf, 5))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
("abcde", buf, 5)), "0" " " "==" " " "strncmp(\"abcde\", buf, 5)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8514, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8515 CHECK_NE(0, strcmp("abcde", buf))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (0), (strcmp
("abcde", buf)), "0" " " "!=" " " "strcmp(\"abcde\", buf)")) {
V8_Fatal("../test/cctest/test-api.cc", 8515, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8516 buf[5] = '\0';
8517 CHECK_EQ(0, strcmp("abcde", buf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("abcde", buf)), "0" " " "==" " " "strcmp(\"abcde\", buf)")) {
V8_Fatal("../test/cctest/test-api.cc", 8517, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8518
8519 memset(utf8buf, 0x1, sizeof(utf8buf));
8520 utf8buf[8] = 'X';
8521 len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen,
8522 String::NO_NULL_TERMINATION);
8523 CHECK_EQ(8, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (len
), "8" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8523, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8524 CHECK_EQ('X', utf8buf[8])do { if (std::string* _msg = ::v8::base::CheckEQImpl( ('X'), (
utf8buf[8]), "'X'" " " "==" " " "utf8buf[8]")) { V8_Fatal("../test/cctest/test-api.cc"
, 8524, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8525 CHECK_EQ(5, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (charlen
), "5" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8525, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8526 CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\342\230\203", 8))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strncmp
(utf8buf, "abc\303\260\342\230\203", 8)), "0" " " "==" " " "strncmp(utf8buf, \"abc\\303\\260\\342\\230\\203\", 8)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8526, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8527 CHECK_NE(0, strcmp(utf8buf, "abc\303\260\342\230\203"))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (0), (strcmp
(utf8buf, "abc\303\260\342\230\203")), "0" " " "!=" " " "strcmp(utf8buf, \"abc\\303\\260\\342\\230\\203\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 8527, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8528 utf8buf[8] = '\0';
8529 CHECK_EQ(0, strcmp(utf8buf, "abc\303\260\342\230\203"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(utf8buf, "abc\303\260\342\230\203")), "0" " " "==" " " "strcmp(utf8buf, \"abc\\303\\260\\342\\230\\203\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 8529, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8530
8531 memset(utf8buf, 0x1, sizeof(utf8buf));
8532 utf8buf[5] = 'X';
8533 len = str->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen,
8534 String::NO_NULL_TERMINATION);
8535 CHECK_EQ(5, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (len
), "5" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8535, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8536 CHECK_EQ('X', utf8buf[5])do { if (std::string* _msg = ::v8::base::CheckEQImpl( ('X'), (
utf8buf[5]), "'X'" " " "==" " " "utf8buf[5]")) { V8_Fatal("../test/cctest/test-api.cc"
, 8536, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
; // Test that the sixth character is untouched.
8537 CHECK_EQ(5, charlen)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (charlen
), "5" " " "==" " " "charlen")) { V8_Fatal("../test/cctest/test-api.cc"
, 8537, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8538 utf8buf[5] = '\0';
8539 CHECK_EQ(0, strcmp(utf8buf, "abcde"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(utf8buf, "abcde")), "0" " " "==" " " "strcmp(utf8buf, \"abcde\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 8539, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8540
8541 memset(buf, 0x1, sizeof(buf));
8542 len = str3->WriteOneByte(reinterpret_cast<uint8_t*>(buf));
8543 CHECK_EQ(7, len)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (len
), "7" " " "==" " " "len")) { V8_Fatal("../test/cctest/test-api.cc"
, 8543, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8544 CHECK_EQ(0, strcmp("abc", buf))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("abc", buf)), "0" " " "==" " " "strcmp(\"abc\", buf)")) { V8_Fatal
("../test/cctest/test-api.cc", 8544, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8545 CHECK_EQ(0, buf[3])do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (buf
[3]), "0" " " "==" " " "buf[3]")) { V8_Fatal("../test/cctest/test-api.cc"
, 8545, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8546 CHECK_EQ(0, strcmp("def", buf + 4))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("def", buf + 4)), "0" " " "==" " " "strcmp(\"def\", buf + 4)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8546, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8547
8548 CHECK_EQ(0, str->WriteOneByte(NULL, 0, 0, String::NO_NULL_TERMINATION))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (str
->WriteOneByte(__null, 0, 0, String::NO_NULL_TERMINATION))
, "0" " " "==" " " "str->WriteOneByte(__null, 0, 0, String::NO_NULL_TERMINATION)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8548, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8549 CHECK_EQ(0, str->WriteUtf8(NULL, 0, 0, String::NO_NULL_TERMINATION))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (str
->WriteUtf8(__null, 0, 0, String::NO_NULL_TERMINATION)), "0"
" " "==" " " "str->WriteUtf8(__null, 0, 0, String::NO_NULL_TERMINATION)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8549, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8550 CHECK_EQ(0, str->Write(NULL, 0, 0, String::NO_NULL_TERMINATION))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (str
->Write(__null, 0, 0, String::NO_NULL_TERMINATION)), "0" " "
"==" " " "str->Write(__null, 0, 0, String::NO_NULL_TERMINATION)"
)) { V8_Fatal("../test/cctest/test-api.cc", 8550, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8551}
8552
8553
8554static void Utf16Helper(
8555 LocalContext& context, // NOLINT
8556 const char* name,
8557 const char* lengths_name,
8558 int len) {
8559 Local<v8::Array> a = Local<v8::Array>::Cast(
8560 context->Global()->Get(context.local(), v8_str(name)).ToLocalChecked());
8561 Local<v8::Array> alens =
8562 Local<v8::Array>::Cast(context->Global()
8563 ->Get(context.local(), v8_str(lengths_name))
8564 .ToLocalChecked());
8565 for (int i = 0; i < len; i++) {
8566 Local<v8::String> string =
8567 Local<v8::String>::Cast(a->Get(context.local(), i).ToLocalChecked());
8568 Local<v8::Number> expected_len = Local<v8::Number>::Cast(
8569 alens->Get(context.local(), i).ToLocalChecked());
8570 int length = GetUtf8Length(string);
8571 CHECK_EQ(static_cast<int>(expected_len->Value()), length)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int>(expected_len->Value())), (length), "static_cast<int>(expected_len->Value())"
" " "==" " " "length")) { V8_Fatal("../test/cctest/test-api.cc"
, 8571, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8572 }
8573}
8574
8575
8576THREADED_TEST(Utf16)static void TestUtf16(); RegisterThreadedTest register_Utf16(
TestUtf16, "Utf16"); static void TestUtf16(); CcTest register_test_Utf16
(TestUtf16, "../test/cctest/test-api.cc", "Utf16", __null, true
, true); static void TestUtf16()
{
8577 LocalContext context;
8578 v8::HandleScope scope(context->GetIsolate());
8579 CompileRun(
8580 "var pad = '01234567890123456789';"
8581 "var p = [];"
8582 "var plens = [20, 3, 3];"
8583 "p.push('01234567890123456789');"
8584 "var lead = 0xd800;"
8585 "var trail = 0xdc00;"
8586 "p.push(String.fromCharCode(0xd800));"
8587 "p.push(String.fromCharCode(0xdc00));"
8588 "var a = [];"
8589 "var b = [];"
8590 "var c = [];"
8591 "var alens = [];"
8592 "for (var i = 0; i < 3; i++) {"
8593 " p[1] = String.fromCharCode(lead++);"
8594 " for (var j = 0; j < 3; j++) {"
8595 " p[2] = String.fromCharCode(trail++);"
8596 " a.push(p[i] + p[j]);"
8597 " b.push(p[i] + p[j]);"
8598 " c.push(p[i] + p[j]);"
8599 " alens.push(plens[i] + plens[j]);"
8600 " }"
8601 "}"
8602 "alens[5] -= 2;" // Here the surrogate pairs match up.
8603 "var a2 = [];"
8604 "var b2 = [];"
8605 "var c2 = [];"
8606 "var a2lens = [];"
8607 "for (var m = 0; m < 9; m++) {"
8608 " for (var n = 0; n < 9; n++) {"
8609 " a2.push(a[m] + a[n]);"
8610 " b2.push(b[m] + b[n]);"
8611 " var newc = 'x' + c[m] + c[n] + 'y';"
8612 " c2.push(newc.substring(1, newc.length - 1));"
8613 " var utf = alens[m] + alens[n];" // And here.
8614 // The 'n's that start with 0xdc.. are 6-8
8615 // The 'm's that end with 0xd8.. are 1, 4 and 7
8616 " if ((m % 3) == 1 && n >= 6) utf -= 2;"
8617 " a2lens.push(utf);"
8618 " }"
8619 "}");
8620 Utf16Helper(context, "a", "alens", 9);
8621 Utf16Helper(context, "a2", "a2lens", 81);
8622}
8623
8624
8625static bool SameSymbol(Local<String> s1, Local<String> s2) {
8626 i::Handle<i::String> is1(v8::Utils::OpenHandle(*s1));
8627 i::Handle<i::String> is2(v8::Utils::OpenHandle(*s2));
8628 return *is1 == *is2;
8629}
8630
8631
8632THREADED_TEST(Utf16Symbol)static void TestUtf16Symbol(); RegisterThreadedTest register_Utf16Symbol
(TestUtf16Symbol, "Utf16Symbol"); static void TestUtf16Symbol
(); CcTest register_test_Utf16Symbol(TestUtf16Symbol, "../test/cctest/test-api.cc"
, "Utf16Symbol", __null, true, true); static void TestUtf16Symbol
()
{
8633 LocalContext context;
8634 v8::HandleScope scope(context->GetIsolate());
8635
8636 Local<String> symbol1 =
8637 v8::String::NewFromUtf8(context->GetIsolate(), "abc",
8638 v8::NewStringType::kInternalized)
8639 .ToLocalChecked();
8640 Local<String> symbol2 =
8641 v8::String::NewFromUtf8(context->GetIsolate(), "abc",
8642 v8::NewStringType::kInternalized)
8643 .ToLocalChecked();
8644 CHECK(SameSymbol(symbol1, symbol2))do { if ((__builtin_expect(!!(!(SameSymbol(symbol1, symbol2))
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8644, "Check failed: %s."
, "SameSymbol(symbol1, symbol2)"); } } while (0)
;
8645
8646 CompileRun(
8647 "var sym0 = 'benedictus';"
8648 "var sym0b = 'S\303\270ren';"
8649 "var sym1 = '\355\240\201\355\260\207';"
8650 "var sym2 = '\360\220\220\210';"
8651 "var sym3 = 'x\355\240\201\355\260\207';"
8652 "var sym4 = 'x\360\220\220\210';"
8653 "if (sym1.length != 2) throw sym1;"
8654 "if (sym1.charCodeAt(1) != 0xdc07) throw sym1.charCodeAt(1);"
8655 "if (sym2.length != 2) throw sym2;"
8656 "if (sym2.charCodeAt(1) != 0xdc08) throw sym2.charCodeAt(2);"
8657 "if (sym3.length != 3) throw sym3;"
8658 "if (sym3.charCodeAt(2) != 0xdc07) throw sym1.charCodeAt(2);"
8659 "if (sym4.length != 3) throw sym4;"
8660 "if (sym4.charCodeAt(2) != 0xdc08) throw sym2.charCodeAt(2);");
8661 Local<String> sym0 =
8662 v8::String::NewFromUtf8(context->GetIsolate(), "benedictus",
8663 v8::NewStringType::kInternalized)
8664 .ToLocalChecked();
8665 Local<String> sym0b =
8666 v8::String::NewFromUtf8(context->GetIsolate(), "S\303\270ren",
8667 v8::NewStringType::kInternalized)
8668 .ToLocalChecked();
8669 Local<String> sym1 =
8670 v8::String::NewFromUtf8(context->GetIsolate(), "\355\240\201\355\260\207",
8671 v8::NewStringType::kInternalized)
8672 .ToLocalChecked();
8673 Local<String> sym2 =
8674 v8::String::NewFromUtf8(context->GetIsolate(), "\360\220\220\210",
8675 v8::NewStringType::kInternalized)
8676 .ToLocalChecked();
8677 Local<String> sym3 = v8::String::NewFromUtf8(context->GetIsolate(),
8678 "x\355\240\201\355\260\207",
8679 v8::NewStringType::kInternalized)
8680 .ToLocalChecked();
8681 Local<String> sym4 =
8682 v8::String::NewFromUtf8(context->GetIsolate(), "x\360\220\220\210",
8683 v8::NewStringType::kInternalized)
8684 .ToLocalChecked();
8685 v8::Local<v8::Object> global = context->Global();
8686 Local<Value> s0 =
8687 global->Get(context.local(), v8_str("sym0")).ToLocalChecked();
8688 Local<Value> s0b =
8689 global->Get(context.local(), v8_str("sym0b")).ToLocalChecked();
8690 Local<Value> s1 =
8691 global->Get(context.local(), v8_str("sym1")).ToLocalChecked();
8692 Local<Value> s2 =
8693 global->Get(context.local(), v8_str("sym2")).ToLocalChecked();
8694 Local<Value> s3 =
8695 global->Get(context.local(), v8_str("sym3")).ToLocalChecked();
8696 Local<Value> s4 =
8697 global->Get(context.local(), v8_str("sym4")).ToLocalChecked();
8698 CHECK(SameSymbol(sym0, Local<String>::Cast(s0)))do { if ((__builtin_expect(!!(!(SameSymbol(sym0, Local<String
>::Cast(s0)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8698, "Check failed: %s.", "SameSymbol(sym0, Local<String>::Cast(s0))"
); } } while (0)
;
8699 CHECK(SameSymbol(sym0b, Local<String>::Cast(s0b)))do { if ((__builtin_expect(!!(!(SameSymbol(sym0b, Local<String
>::Cast(s0b)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8699, "Check failed: %s.", "SameSymbol(sym0b, Local<String>::Cast(s0b))"
); } } while (0)
;
8700 CHECK(SameSymbol(sym1, Local<String>::Cast(s1)))do { if ((__builtin_expect(!!(!(SameSymbol(sym1, Local<String
>::Cast(s1)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8700, "Check failed: %s.", "SameSymbol(sym1, Local<String>::Cast(s1))"
); } } while (0)
;
8701 CHECK(SameSymbol(sym2, Local<String>::Cast(s2)))do { if ((__builtin_expect(!!(!(SameSymbol(sym2, Local<String
>::Cast(s2)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8701, "Check failed: %s.", "SameSymbol(sym2, Local<String>::Cast(s2))"
); } } while (0)
;
8702 CHECK(SameSymbol(sym3, Local<String>::Cast(s3)))do { if ((__builtin_expect(!!(!(SameSymbol(sym3, Local<String
>::Cast(s3)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8702, "Check failed: %s.", "SameSymbol(sym3, Local<String>::Cast(s3))"
); } } while (0)
;
8703 CHECK(SameSymbol(sym4, Local<String>::Cast(s4)))do { if ((__builtin_expect(!!(!(SameSymbol(sym4, Local<String
>::Cast(s4)))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8703, "Check failed: %s.", "SameSymbol(sym4, Local<String>::Cast(s4))"
); } } while (0)
;
8704}
8705
8706
8707THREADED_TEST(Utf16MissingTrailing)static void TestUtf16MissingTrailing(); RegisterThreadedTest register_Utf16MissingTrailing
(TestUtf16MissingTrailing, "Utf16MissingTrailing"); static void
TestUtf16MissingTrailing(); CcTest register_test_Utf16MissingTrailing
(TestUtf16MissingTrailing, "../test/cctest/test-api.cc", "Utf16MissingTrailing"
, __null, true, true); static void TestUtf16MissingTrailing()
{
8708 LocalContext context;
8709 v8::HandleScope scope(context->GetIsolate());
8710
8711 // Make sure it will go past the buffer, so it will call `WriteUtf16Slow`
8712 int size = 1024 * 64;
8713 uint8_t* buffer = new uint8_t[size];
8714 for (int i = 0; i < size; i += 4) {
8715 buffer[i] = 0xf0;
8716 buffer[i + 1] = 0x9d;
8717 buffer[i + 2] = 0x80;
8718 buffer[i + 3] = 0x9e;
8719 }
8720
8721 // Now invoke the decoder without last 3 bytes
8722 v8::Local<v8::String> str =
8723 v8::String::NewFromUtf8(
8724 context->GetIsolate(), reinterpret_cast<char*>(buffer),
8725 v8::NewStringType::kNormal, size - 3).ToLocalChecked();
8726 USE(str);
8727 delete[] buffer;
8728}
8729
8730
8731THREADED_TEST(Utf16Trailing3Byte)static void TestUtf16Trailing3Byte(); RegisterThreadedTest register_Utf16Trailing3Byte
(TestUtf16Trailing3Byte, "Utf16Trailing3Byte"); static void TestUtf16Trailing3Byte
(); CcTest register_test_Utf16Trailing3Byte(TestUtf16Trailing3Byte
, "../test/cctest/test-api.cc", "Utf16Trailing3Byte", __null,
true, true); static void TestUtf16Trailing3Byte()
{
8732 LocalContext context;
8733 v8::HandleScope scope(context->GetIsolate());
8734
8735 // Make sure it will go past the buffer, so it will call `WriteUtf16Slow`
8736 int size = 1024 * 63;
8737 uint8_t* buffer = new uint8_t[size];
8738 for (int i = 0; i < size; i += 3) {
8739 buffer[i] = 0xe2;
8740 buffer[i + 1] = 0x80;
8741 buffer[i + 2] = 0xa6;
8742 }
8743
8744 // Now invoke the decoder without last 3 bytes
8745 v8::Local<v8::String> str =
8746 v8::String::NewFromUtf8(
8747 context->GetIsolate(), reinterpret_cast<char*>(buffer),
8748 v8::NewStringType::kNormal, size).ToLocalChecked();
8749
8750 v8::String::Value value(str);
8751 CHECK_EQ(value.length(), size / 3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (value.
length()), (size / 3), "value.length()" " " "==" " " "size / 3"
)) { V8_Fatal("../test/cctest/test-api.cc", 8751, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8752 CHECK_EQ((*value)[value.length() - 1], 0x2026)do { if (std::string* _msg = ::v8::base::CheckEQImpl( ((*value
)[value.length() - 1]), (0x2026), "(*value)[value.length() - 1]"
" " "==" " " "0x2026")) { V8_Fatal("../test/cctest/test-api.cc"
, 8752, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
8753
8754 delete[] buffer;
8755}
8756
8757
8758THREADED_TEST(ToArrayIndex)static void TestToArrayIndex(); RegisterThreadedTest register_ToArrayIndex
(TestToArrayIndex, "ToArrayIndex"); static void TestToArrayIndex
(); CcTest register_test_ToArrayIndex(TestToArrayIndex, "../test/cctest/test-api.cc"
, "ToArrayIndex", __null, true, true); static void TestToArrayIndex
()
{
8759 LocalContext context;
8760 v8::Isolate* isolate = context->GetIsolate();
8761 v8::HandleScope scope(isolate);
8762
8763 v8::Local<String> str = v8_str("42");
8764 v8::MaybeLocal<v8::Uint32> index = str->ToArrayIndex(context.local());
8765 CHECK(!index.IsEmpty())do { if ((__builtin_expect(!!(!(!index.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8765, "Check failed: %s.", "!index.IsEmpty()"
); } } while (0)
;
8766 CHECK_EQ(42.0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(index.ToLocalChecked()->Uint32Value(context.local()).FromJust
()), "42.0" " " "==" " " "index.ToLocalChecked()->Uint32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8767, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
8767 index.ToLocalChecked()->Uint32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(index.ToLocalChecked()->Uint32Value(context.local()).FromJust
()), "42.0" " " "==" " " "index.ToLocalChecked()->Uint32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8767, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8768 str = v8_str("42asdf");
8769 index = str->ToArrayIndex(context.local());
8770 CHECK(index.IsEmpty())do { if ((__builtin_expect(!!(!(index.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8770, "Check failed: %s.", "index.IsEmpty()"
); } } while (0)
;
8771 str = v8_str("-42");
8772 index = str->ToArrayIndex(context.local());
8773 CHECK(index.IsEmpty())do { if ((__builtin_expect(!!(!(index.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8773, "Check failed: %s.", "index.IsEmpty()"
); } } while (0)
;
8774 str = v8_str("4294967294");
8775 index = str->ToArrayIndex(context.local());
8776 CHECK(!index.IsEmpty())do { if ((__builtin_expect(!!(!(!index.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8776, "Check failed: %s.", "!index.IsEmpty()"
); } } while (0)
;
8777 CHECK_EQ(4294967294.0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4294967294.0
), (index.ToLocalChecked()->Uint32Value(context.local()).FromJust
()), "4294967294.0" " " "==" " " "index.ToLocalChecked()->Uint32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8778, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
8778 index.ToLocalChecked()->Uint32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4294967294.0
), (index.ToLocalChecked()->Uint32Value(context.local()).FromJust
()), "4294967294.0" " " "==" " " "index.ToLocalChecked()->Uint32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8778, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8779 v8::Local<v8::Number> num = v8::Number::New(isolate, 1);
8780 index = num->ToArrayIndex(context.local());
8781 CHECK(!index.IsEmpty())do { if ((__builtin_expect(!!(!(!index.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8781, "Check failed: %s.", "!index.IsEmpty()"
); } } while (0)
;
8782 CHECK_EQ(1.0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.0), (
index.ToLocalChecked()->Uint32Value(context.local()).FromJust
()), "1.0" " " "==" " " "index.ToLocalChecked()->Uint32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8783, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
8783 index.ToLocalChecked()->Uint32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1.0), (
index.ToLocalChecked()->Uint32Value(context.local()).FromJust
()), "1.0" " " "==" " " "index.ToLocalChecked()->Uint32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8783, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8784 num = v8::Number::New(isolate, -1);
8785 index = num->ToArrayIndex(context.local());
8786 CHECK(index.IsEmpty())do { if ((__builtin_expect(!!(!(index.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8786, "Check failed: %s.", "index.IsEmpty()"
); } } while (0)
;
8787 v8::Local<v8::Object> obj = v8::Object::New(isolate);
8788 index = obj->ToArrayIndex(context.local());
8789 CHECK(index.IsEmpty())do { if ((__builtin_expect(!!(!(index.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8789, "Check failed: %s.", "index.IsEmpty()"
); } } while (0)
;
8790}
8791
8792
8793THREADED_TEST(ErrorConstruction)static void TestErrorConstruction(); RegisterThreadedTest register_ErrorConstruction
(TestErrorConstruction, "ErrorConstruction"); static void TestErrorConstruction
(); CcTest register_test_ErrorConstruction(TestErrorConstruction
, "../test/cctest/test-api.cc", "ErrorConstruction", __null, true
, true); static void TestErrorConstruction()
{
8794 LocalContext context;
8795 v8::HandleScope scope(context->GetIsolate());
8796
8797 v8::Local<String> foo = v8_str("foo");
8798 v8::Local<String> message = v8_str("message");
8799 v8::Local<Value> range_error = v8::Exception::RangeError(foo);
8800 CHECK(range_error->IsObject())do { if ((__builtin_expect(!!(!(range_error->IsObject())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 8800, "Check failed: %s."
, "range_error->IsObject()"); } } while (0)
;
8801 CHECK(range_error.As<v8::Object>()do { if ((__builtin_expect(!!(!(range_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8805, "Check failed: %s.", "range_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8802 ->Get(context.local(), message)do { if ((__builtin_expect(!!(!(range_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8805, "Check failed: %s.", "range_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8803 .ToLocalChecked()do { if ((__builtin_expect(!!(!(range_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8805, "Check failed: %s.", "range_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8804 ->Equals(context.local(), foo)do { if ((__builtin_expect(!!(!(range_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8805, "Check failed: %s.", "range_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8805 .FromJust())do { if ((__builtin_expect(!!(!(range_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8805, "Check failed: %s.", "range_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
;
8806 v8::Local<Value> reference_error = v8::Exception::ReferenceError(foo);
8807 CHECK(reference_error->IsObject())do { if ((__builtin_expect(!!(!(reference_error->IsObject(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8807, "Check failed: %s."
, "reference_error->IsObject()"); } } while (0)
;
8808 CHECK(reference_error.As<v8::Object>()do { if ((__builtin_expect(!!(!(reference_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8812, "Check failed: %s.", "reference_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8809 ->Get(context.local(), message)do { if ((__builtin_expect(!!(!(reference_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8812, "Check failed: %s.", "reference_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8810 .ToLocalChecked()do { if ((__builtin_expect(!!(!(reference_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8812, "Check failed: %s.", "reference_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8811 ->Equals(context.local(), foo)do { if ((__builtin_expect(!!(!(reference_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8812, "Check failed: %s.", "reference_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8812 .FromJust())do { if ((__builtin_expect(!!(!(reference_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8812, "Check failed: %s.", "reference_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
;
8813 v8::Local<Value> syntax_error = v8::Exception::SyntaxError(foo);
8814 CHECK(syntax_error->IsObject())do { if ((__builtin_expect(!!(!(syntax_error->IsObject()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 8814, "Check failed: %s."
, "syntax_error->IsObject()"); } } while (0)
;
8815 CHECK(syntax_error.As<v8::Object>()do { if ((__builtin_expect(!!(!(syntax_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8819, "Check failed: %s.", "syntax_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8816 ->Get(context.local(), message)do { if ((__builtin_expect(!!(!(syntax_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8819, "Check failed: %s.", "syntax_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8817 .ToLocalChecked()do { if ((__builtin_expect(!!(!(syntax_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8819, "Check failed: %s.", "syntax_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8818 ->Equals(context.local(), foo)do { if ((__builtin_expect(!!(!(syntax_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8819, "Check failed: %s.", "syntax_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8819 .FromJust())do { if ((__builtin_expect(!!(!(syntax_error.As<v8::Object
>() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8819, "Check failed: %s.", "syntax_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
;
8820 v8::Local<Value> type_error = v8::Exception::TypeError(foo);
8821 CHECK(type_error->IsObject())do { if ((__builtin_expect(!!(!(type_error->IsObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 8821, "Check failed: %s."
, "type_error->IsObject()"); } } while (0)
;
8822 CHECK(type_error.As<v8::Object>()do { if ((__builtin_expect(!!(!(type_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8826, "Check failed: %s.", "type_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8823 ->Get(context.local(), message)do { if ((__builtin_expect(!!(!(type_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8826, "Check failed: %s.", "type_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8824 .ToLocalChecked()do { if ((__builtin_expect(!!(!(type_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8826, "Check failed: %s.", "type_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8825 ->Equals(context.local(), foo)do { if ((__builtin_expect(!!(!(type_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8826, "Check failed: %s.", "type_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8826 .FromJust())do { if ((__builtin_expect(!!(!(type_error.As<v8::Object>
() ->Get(context.local(), message) .ToLocalChecked() ->
Equals(context.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8826, "Check failed: %s.", "type_error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
;
8827 v8::Local<Value> error = v8::Exception::Error(foo);
8828 CHECK(error->IsObject())do { if ((__builtin_expect(!!(!(error->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 8828, "Check failed: %s."
, "error->IsObject()"); } } while (0)
;
8829 CHECK(error.As<v8::Object>()do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message) .ToLocalChecked() ->Equals(context
.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8833, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8830 ->Get(context.local(), message)do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message) .ToLocalChecked() ->Equals(context
.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8833, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8831 .ToLocalChecked()do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message) .ToLocalChecked() ->Equals(context
.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8833, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8832 ->Equals(context.local(), foo)do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message) .ToLocalChecked() ->Equals(context
.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8833, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
8833 .FromJust())do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message) .ToLocalChecked() ->Equals(context
.local(), foo) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8833, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message) .ToLocalChecked() ->Equals(context.local(), foo) .FromJust()"
); } } while (0)
;
8834}
8835
8836
8837static void ThrowV8Exception(const v8::FunctionCallbackInfo<v8::Value>& info) {
8838 ApiTestFuzzer::Fuzz();
8839 v8::Local<String> foo = v8_str("foo");
8840 v8::Local<String> message = v8_str("message");
8841 v8::Local<Value> error = v8::Exception::Error(foo);
8842 CHECK(error->IsObject())do { if ((__builtin_expect(!!(!(error->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 8842, "Check failed: %s."
, "error->IsObject()"); } } while (0)
;
8843 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
8844 CHECK(error.As<v8::Object>()do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context, message) .ToLocalChecked() ->Equals(context, foo
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8848, "Check failed: %s.", "error.As<v8::Object>() ->Get(context, message) .ToLocalChecked() ->Equals(context, foo) .FromJust()"
); } } while (0)
8845 ->Get(context, message)do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context, message) .ToLocalChecked() ->Equals(context, foo
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8848, "Check failed: %s.", "error.As<v8::Object>() ->Get(context, message) .ToLocalChecked() ->Equals(context, foo) .FromJust()"
); } } while (0)
8846 .ToLocalChecked()do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context, message) .ToLocalChecked() ->Equals(context, foo
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8848, "Check failed: %s.", "error.As<v8::Object>() ->Get(context, message) .ToLocalChecked() ->Equals(context, foo) .FromJust()"
); } } while (0)
8847 ->Equals(context, foo)do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context, message) .ToLocalChecked() ->Equals(context, foo
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8848, "Check failed: %s.", "error.As<v8::Object>() ->Get(context, message) .ToLocalChecked() ->Equals(context, foo) .FromJust()"
); } } while (0)
8848 .FromJust())do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context, message) .ToLocalChecked() ->Equals(context, foo
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8848, "Check failed: %s.", "error.As<v8::Object>() ->Get(context, message) .ToLocalChecked() ->Equals(context, foo) .FromJust()"
); } } while (0)
;
8849 info.GetIsolate()->ThrowException(error);
8850 info.GetReturnValue().SetUndefined();
8851}
8852
8853
8854THREADED_TEST(ExceptionCreateMessage)static void TestExceptionCreateMessage(); RegisterThreadedTest
register_ExceptionCreateMessage(TestExceptionCreateMessage, "ExceptionCreateMessage"
); static void TestExceptionCreateMessage(); CcTest register_test_ExceptionCreateMessage
(TestExceptionCreateMessage, "../test/cctest/test-api.cc", "ExceptionCreateMessage"
, __null, true, true); static void TestExceptionCreateMessage
()
{
8855 LocalContext context;
8856 v8::HandleScope scope(context->GetIsolate());
8857 v8::Local<String> foo_str = v8_str("foo");
8858 v8::Local<String> message_str = v8_str("message");
8859
8860 context->GetIsolate()->SetCaptureStackTraceForUncaughtExceptions(true);
8861
8862 Local<v8::FunctionTemplate> fun =
8863 v8::FunctionTemplate::New(context->GetIsolate(), ThrowV8Exception);
8864 v8::Local<v8::Object> global = context->Global();
8865 CHECK(global->Set(context.local(), v8_str("throwV8Exception"),do { if ((__builtin_expect(!!(!(global->Set(context.local(
), v8_str("throwV8Exception"), fun->GetFunction(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8867, "Check failed: %s.", "global->Set(context.local(), v8_str(\"throwV8Exception\"), fun->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
8866 fun->GetFunction(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(global->Set(context.local(
), v8_str("throwV8Exception"), fun->GetFunction(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8867, "Check failed: %s.", "global->Set(context.local(), v8_str(\"throwV8Exception\"), fun->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
8867 .FromJust())do { if ((__builtin_expect(!!(!(global->Set(context.local(
), v8_str("throwV8Exception"), fun->GetFunction(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8867, "Check failed: %s.", "global->Set(context.local(), v8_str(\"throwV8Exception\"), fun->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
8868
8869 TryCatch try_catch(context->GetIsolate());
8870 CompileRun(
8871 "function f1() {\n"
8872 " throwV8Exception();\n"
8873 "};\n"
8874 "f1();");
8875 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 8875, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
8876
8877 v8::Local<v8::Value> error = try_catch.Exception();
8878 CHECK(error->IsObject())do { if ((__builtin_expect(!!(!(error->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 8878, "Check failed: %s."
, "error->IsObject()"); } } while (0)
;
8879 CHECK(error.As<v8::Object>()do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8883, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
8880 ->Get(context.local(), message_str)do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8883, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
8881 .ToLocalChecked()do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8883, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
8882 ->Equals(context.local(), foo_str)do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8883, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
8883 .FromJust())do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8883, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
;
8884
8885 v8::Local<v8::Message> message =
8886 v8::Exception::CreateMessage(context->GetIsolate(), error);
8887 CHECK(!message.IsEmpty())do { if ((__builtin_expect(!!(!(!message.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8887, "Check failed: %s.", "!message.IsEmpty()"
); } } while (0)
;
8888 CHECK_EQ(2, message->GetLineNumber(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (message
->GetLineNumber(context.local()).FromJust()), "2" " " "=="
" " "message->GetLineNumber(context.local()).FromJust()")
) { V8_Fatal("../test/cctest/test-api.cc", 8888, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8889 CHECK_EQ(2, message->GetStartColumn(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (message
->GetStartColumn(context.local()).FromJust()), "2" " " "=="
" " "message->GetStartColumn(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8889, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8890
8891 v8::Local<v8::StackTrace> stackTrace = message->GetStackTrace();
8892 CHECK(!stackTrace.IsEmpty())do { if ((__builtin_expect(!!(!(!stackTrace.IsEmpty())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 8892, "Check failed: %s."
, "!stackTrace.IsEmpty()"); } } while (0)
;
8893 CHECK_EQ(2, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (stackTrace
->GetFrameCount()), "2" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8893, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8894
8895 stackTrace = v8::Exception::GetStackTrace(error);
8896 CHECK(!stackTrace.IsEmpty())do { if ((__builtin_expect(!!(!(!stackTrace.IsEmpty())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 8896, "Check failed: %s."
, "!stackTrace.IsEmpty()"); } } while (0)
;
8897 CHECK_EQ(2, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (stackTrace
->GetFrameCount()), "2" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8897, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8898
8899 context->GetIsolate()->SetCaptureStackTraceForUncaughtExceptions(false);
8900
8901 // Now check message location when SetCaptureStackTraceForUncaughtExceptions
8902 // is false.
8903 try_catch.Reset();
8904
8905 CompileRun(
8906 "function f2() {\n"
8907 " return throwV8Exception();\n"
8908 "};\n"
8909 "f2();");
8910 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 8910, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
8911
8912 error = try_catch.Exception();
8913 CHECK(error->IsObject())do { if ((__builtin_expect(!!(!(error->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 8913, "Check failed: %s."
, "error->IsObject()"); } } while (0)
;
8914 CHECK(error.As<v8::Object>()do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8918, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
8915 ->Get(context.local(), message_str)do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8918, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
8916 .ToLocalChecked()do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8918, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
8917 ->Equals(context.local(), foo_str)do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8918, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
8918 .FromJust())do { if ((__builtin_expect(!!(!(error.As<v8::Object>() ->
Get(context.local(), message_str) .ToLocalChecked() ->Equals
(context.local(), foo_str) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8918, "Check failed: %s.", "error.As<v8::Object>() ->Get(context.local(), message_str) .ToLocalChecked() ->Equals(context.local(), foo_str) .FromJust()"
); } } while (0)
;
8919
8920 message = v8::Exception::CreateMessage(context->GetIsolate(), error);
8921 CHECK(!message.IsEmpty())do { if ((__builtin_expect(!!(!(!message.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 8921, "Check failed: %s.", "!message.IsEmpty()"
); } } while (0)
;
8922 CHECK_EQ(2, message->GetLineNumber(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (message
->GetLineNumber(context.local()).FromJust()), "2" " " "=="
" " "message->GetLineNumber(context.local()).FromJust()")
) { V8_Fatal("../test/cctest/test-api.cc", 8922, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8923 CHECK_EQ(9, message->GetStartColumn(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9), (message
->GetStartColumn(context.local()).FromJust()), "9" " " "=="
" " "message->GetStartColumn(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8923, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8924
8925 // Should be empty stack trace.
8926 stackTrace = message->GetStackTrace();
8927 CHECK(stackTrace.IsEmpty())do { if ((__builtin_expect(!!(!(stackTrace.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 8927, "Check failed: %s."
, "stackTrace.IsEmpty()"); } } while (0)
;
8928 CHECK(v8::Exception::GetStackTrace(error).IsEmpty())do { if ((__builtin_expect(!!(!(v8::Exception::GetStackTrace(
error).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8928, "Check failed: %s.", "v8::Exception::GetStackTrace(error).IsEmpty()"
); } } while (0)
;
8929}
8930
8931
8932THREADED_TEST(ExceptionCreateMessageLength)static void TestExceptionCreateMessageLength(); RegisterThreadedTest
register_ExceptionCreateMessageLength(TestExceptionCreateMessageLength
, "ExceptionCreateMessageLength"); static void TestExceptionCreateMessageLength
(); CcTest register_test_ExceptionCreateMessageLength(TestExceptionCreateMessageLength
, "../test/cctest/test-api.cc", "ExceptionCreateMessageLength"
, __null, true, true); static void TestExceptionCreateMessageLength
()
{
8933 LocalContext context;
8934 v8::HandleScope scope(context->GetIsolate());
8935
8936 // Test that the message is not truncated.
8937 TryCatch try_catch(context->GetIsolate());
8938 CompileRun(
8939 "var message = 'm';"
8940 "while (message.length < 1000) message += message;"
8941 "throw message;");
8942 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 8942, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
8943
8944 CHECK_LT(1000, try_catch.Message()->Get()->Length())do { if (std::string* _msg = ::v8::base::CheckLTImpl( (1000),
(try_catch.Message()->Get()->Length()), "1000" " " "<"
" " "try_catch.Message()->Get()->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 8944, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
8945}
8946
8947
8948static void YGetter(Local<String> name,
8949 const v8::PropertyCallbackInfo<v8::Value>& info) {
8950 ApiTestFuzzer::Fuzz();
8951 info.GetReturnValue().Set(v8_num(10));
8952}
8953
8954
8955static void YSetter(Local<String> name,
8956 Local<Value> value,
8957 const v8::PropertyCallbackInfo<void>& info) {
8958 Local<Object> this_obj = Local<Object>::Cast(info.This());
8959 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
8960 if (this_obj->Has(context, name).FromJust())
8961 this_obj->Delete(context, name).FromJust();
8962 CHECK(this_obj->Set(context, name, value).FromJust())do { if ((__builtin_expect(!!(!(this_obj->Set(context, name
, value).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 8962, "Check failed: %s.", "this_obj->Set(context, name, value).FromJust()"
); } } while (0)
;
8963}
8964
8965
8966THREADED_TEST(DeleteAccessor)static void TestDeleteAccessor(); RegisterThreadedTest register_DeleteAccessor
(TestDeleteAccessor, "DeleteAccessor"); static void TestDeleteAccessor
(); CcTest register_test_DeleteAccessor(TestDeleteAccessor, "../test/cctest/test-api.cc"
, "DeleteAccessor", __null, true, true); static void TestDeleteAccessor
()
{
8967 v8::Isolate* isolate = CcTest::isolate();
8968 v8::HandleScope scope(isolate);
8969 v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
8970 obj->SetAccessor(v8_str("y"), YGetter, YSetter);
8971 LocalContext context;
8972 v8::Local<v8::Object> holder =
8973 obj->NewInstance(context.local()).ToLocalChecked();
8974 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("holder"), holder) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 8976, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"holder\"), holder) .FromJust()"
); } } while (0)
8975 ->Set(context.local(), v8_str("holder"), holder)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("holder"), holder) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 8976, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"holder\"), holder) .FromJust()"
); } } while (0)
8976 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("holder"), holder) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 8976, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"holder\"), holder) .FromJust()"
); } } while (0)
;
8977 v8::Local<Value> result =
8978 CompileRun("holder.y = 11; holder.y = 12; holder.y");
8979 CHECK_EQ(12u, result->Uint32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12u), (
result->Uint32Value(context.local()).FromJust()), "12u" " "
"==" " " "result->Uint32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 8979, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
8980}
8981
8982
8983static int trouble_nesting = 0;
8984static void TroubleCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
8985 ApiTestFuzzer::Fuzz();
8986 trouble_nesting++;
8987
8988 // Call a JS function that throws an uncaught exception.
8989 Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
8990 Local<v8::Object> arg_this = context->Global();
8991 Local<Value> trouble_callee =
8992 (trouble_nesting == 3)
8993 ? arg_this->Get(context, v8_str("trouble_callee")).ToLocalChecked()
8994 : arg_this->Get(context, v8_str("trouble_caller")).ToLocalChecked();
8995 CHECK(trouble_callee->IsFunction())do { if ((__builtin_expect(!!(!(trouble_callee->IsFunction
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 8995, "Check failed: %s."
, "trouble_callee->IsFunction()"); } } while (0)
;
8996 args.GetReturnValue().Set(Function::Cast(*trouble_callee)
8997 ->Call(context, arg_this, 0, NULL__null)
8998 .FromMaybe(v8::Local<v8::Value>()));
8999}
9000
9001
9002static int report_count = 0;
9003static void ApiUncaughtExceptionTestListener(v8::Local<v8::Message>,
9004 v8::Local<Value>) {
9005 report_count++;
9006}
9007
9008
9009// Counts uncaught exceptions, but other tests running in parallel
9010// also have uncaught exceptions.
9011TEST(ApiUncaughtException)static void TestApiUncaughtException(); CcTest register_test_ApiUncaughtException
(TestApiUncaughtException, "../test/cctest/test-api.cc", "ApiUncaughtException"
, __null, true, true); static void TestApiUncaughtException()
{
9012 report_count = 0;
9013 LocalContext env;
9014 v8::Isolate* isolate = env->GetIsolate();
9015 v8::HandleScope scope(isolate);
9016 isolate->AddMessageListener(ApiUncaughtExceptionTestListener);
9017
9018 Local<v8::FunctionTemplate> fun =
9019 v8::FunctionTemplate::New(isolate, TroubleCallback);
9020 v8::Local<v8::Object> global = env->Global();
9021 CHECK(global->Set(env.local(), v8_str("trouble"),do { if ((__builtin_expect(!!(!(global->Set(env.local(), v8_str
("trouble"), fun->GetFunction(env.local()).ToLocalChecked(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9023, "Check failed: %s.", "global->Set(env.local(), v8_str(\"trouble\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
9022 fun->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(global->Set(env.local(), v8_str
("trouble"), fun->GetFunction(env.local()).ToLocalChecked(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9023, "Check failed: %s.", "global->Set(env.local(), v8_str(\"trouble\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
9023 .FromJust())do { if ((__builtin_expect(!!(!(global->Set(env.local(), v8_str
("trouble"), fun->GetFunction(env.local()).ToLocalChecked(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9023, "Check failed: %s.", "global->Set(env.local(), v8_str(\"trouble\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9024
9025 CompileRun(
9026 "function trouble_callee() {"
9027 " var x = null;"
9028 " return x.foo;"
9029 "};"
9030 "function trouble_caller() {"
9031 " trouble();"
9032 "};");
9033 Local<Value> trouble =
9034 global->Get(env.local(), v8_str("trouble")).ToLocalChecked();
9035 CHECK(trouble->IsFunction())do { if ((__builtin_expect(!!(!(trouble->IsFunction())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9035, "Check failed: %s."
, "trouble->IsFunction()"); } } while (0)
;
9036 Local<Value> trouble_callee =
9037 global->Get(env.local(), v8_str("trouble_callee")).ToLocalChecked();
9038 CHECK(trouble_callee->IsFunction())do { if ((__builtin_expect(!!(!(trouble_callee->IsFunction
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9038, "Check failed: %s."
, "trouble_callee->IsFunction()"); } } while (0)
;
9039 Local<Value> trouble_caller =
9040 global->Get(env.local(), v8_str("trouble_caller")).ToLocalChecked();
9041 CHECK(trouble_caller->IsFunction())do { if ((__builtin_expect(!!(!(trouble_caller->IsFunction
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9041, "Check failed: %s."
, "trouble_caller->IsFunction()"); } } while (0)
;
9042 Function::Cast(*trouble_caller)
9043 ->Call(env.local(), global, 0, NULL__null)
9044 .FromMaybe(v8::Local<v8::Value>());
9045 CHECK_EQ(1, report_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (report_count
), "1" " " "==" " " "report_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 9045, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
9046 isolate->RemoveMessageListeners(ApiUncaughtExceptionTestListener);
9047}
9048
9049
9050TEST(ApiUncaughtExceptionInObjectObserve)static void TestApiUncaughtExceptionInObjectObserve(); CcTest
register_test_ApiUncaughtExceptionInObjectObserve(TestApiUncaughtExceptionInObjectObserve
, "../test/cctest/test-api.cc", "ApiUncaughtExceptionInObjectObserve"
, __null, true, true); static void TestApiUncaughtExceptionInObjectObserve
()
{
9051 v8::internal::FLAG_harmony_object_observe = true;
9052 v8::internal::FLAG_stack_size = 150;
9053 report_count = 0;
9054 LocalContext env;
9055 v8::Isolate* isolate = env->GetIsolate();
9056 v8::HandleScope scope(isolate);
9057 isolate->AddMessageListener(ApiUncaughtExceptionTestListener);
9058 CompileRun(
9059 "var obj = {};"
9060 "var observe_count = 0;"
9061 "function observer1() { ++observe_count; };"
9062 "function observer2() { ++observe_count; };"
9063 "function observer_throws() { throw new Error(); };"
9064 "function stack_overflow() { return (function f(x) { f(x+1); })(0); };"
9065 "Object.observe(obj, observer_throws.bind());"
9066 "Object.observe(obj, observer1);"
9067 "Object.observe(obj, stack_overflow);"
9068 "Object.observe(obj, observer2);"
9069 "Object.observe(obj, observer_throws.bind());"
9070 "obj.foo = 'bar';");
9071 CHECK_EQ(3, report_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (report_count
), "3" " " "==" " " "report_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 9071, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
9072 ExpectInt32("observe_count", 2);
9073 isolate->RemoveMessageListeners(ApiUncaughtExceptionTestListener);
9074}
9075
9076
9077static const char* script_resource_name = "ExceptionInNativeScript.js";
9078static void ExceptionInNativeScriptTestListener(v8::Local<v8::Message> message,
9079 v8::Local<Value>) {
9080 v8::Local<v8::Value> name_val = message->GetScriptOrigin().ResourceName();
9081 CHECK(!name_val.IsEmpty() && name_val->IsString())do { if ((__builtin_expect(!!(!(!name_val.IsEmpty() &&
name_val->IsString())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9081, "Check failed: %s.", "!name_val.IsEmpty() && name_val->IsString()"
); } } while (0)
;
9082 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName());
9083 CHECK_EQ(0, strcmp(script_resource_name, *name))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(script_resource_name, *name)), "0" " " "==" " " "strcmp(script_resource_name, *name)"
)) { V8_Fatal("../test/cctest/test-api.cc", 9083, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9084 v8::Local<v8::Context> context =
9085 v8::Isolate::GetCurrent()->GetCurrentContext();
9086 CHECK_EQ(3, message->GetLineNumber(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (message
->GetLineNumber(context).FromJust()), "3" " " "==" " " "message->GetLineNumber(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9086, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9087 v8::String::Utf8Value source_line(
9088 message->GetSourceLine(context).ToLocalChecked());
9089 CHECK_EQ(0, strcmp(" new o.foo();", *source_line))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(" new o.foo();", *source_line)), "0" " " "==" " " "strcmp(\" new o.foo();\", *source_line)"
)) { V8_Fatal("../test/cctest/test-api.cc", 9089, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9090}
9091
9092
9093TEST(ExceptionInNativeScript)static void TestExceptionInNativeScript(); CcTest register_test_ExceptionInNativeScript
(TestExceptionInNativeScript, "../test/cctest/test-api.cc", "ExceptionInNativeScript"
, __null, true, true); static void TestExceptionInNativeScript
()
{
9094 LocalContext env;
9095 v8::Isolate* isolate = env->GetIsolate();
9096 v8::HandleScope scope(isolate);
9097 isolate->AddMessageListener(ExceptionInNativeScriptTestListener);
9098
9099 Local<v8::FunctionTemplate> fun =
9100 v8::FunctionTemplate::New(isolate, TroubleCallback);
9101 v8::Local<v8::Object> global = env->Global();
9102 CHECK(global->Set(env.local(), v8_str("trouble"),do { if ((__builtin_expect(!!(!(global->Set(env.local(), v8_str
("trouble"), fun->GetFunction(env.local()).ToLocalChecked(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9104, "Check failed: %s.", "global->Set(env.local(), v8_str(\"trouble\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
9103 fun->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(global->Set(env.local(), v8_str
("trouble"), fun->GetFunction(env.local()).ToLocalChecked(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9104, "Check failed: %s.", "global->Set(env.local(), v8_str(\"trouble\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
9104 .FromJust())do { if ((__builtin_expect(!!(!(global->Set(env.local(), v8_str
("trouble"), fun->GetFunction(env.local()).ToLocalChecked(
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9104, "Check failed: %s.", "global->Set(env.local(), v8_str(\"trouble\"), fun->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9105
9106 CompileRunWithOrigin(
9107 "function trouble() {\n"
9108 " var o = {};\n"
9109 " new o.foo();\n"
9110 "};",
9111 script_resource_name);
9112 Local<Value> trouble =
9113 global->Get(env.local(), v8_str("trouble")).ToLocalChecked();
9114 CHECK(trouble->IsFunction())do { if ((__builtin_expect(!!(!(trouble->IsFunction())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9114, "Check failed: %s."
, "trouble->IsFunction()"); } } while (0)
;
9115 CHECK(Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).IsEmpty())do { if ((__builtin_expect(!!(!(Function::Cast(*trouble)->
Call(env.local(), global, 0, __null).IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9115, "Check failed: %s.", "Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).IsEmpty()"
); } } while (0)
;
9116 isolate->RemoveMessageListeners(ExceptionInNativeScriptTestListener);
9117}
9118
9119
9120TEST(CompilationErrorUsingTryCatchHandler)static void TestCompilationErrorUsingTryCatchHandler(); CcTest
register_test_CompilationErrorUsingTryCatchHandler(TestCompilationErrorUsingTryCatchHandler
, "../test/cctest/test-api.cc", "CompilationErrorUsingTryCatchHandler"
, __null, true, true); static void TestCompilationErrorUsingTryCatchHandler
()
{
9121 LocalContext env;
9122 v8::HandleScope scope(env->GetIsolate());
9123 v8::TryCatch try_catch(env->GetIsolate());
9124 v8_compile("This doesn't &*&@#$&*^ compile.");
9125 CHECK(*try_catch.Exception())do { if ((__builtin_expect(!!(!(*try_catch.Exception())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 9125, "Check failed: %s."
, "*try_catch.Exception()"); } } while (0)
;
9126 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 9126, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
9127}
9128
9129
9130TEST(TryCatchFinallyUsingTryCatchHandler)static void TestTryCatchFinallyUsingTryCatchHandler(); CcTest
register_test_TryCatchFinallyUsingTryCatchHandler(TestTryCatchFinallyUsingTryCatchHandler
, "../test/cctest/test-api.cc", "TryCatchFinallyUsingTryCatchHandler"
, __null, true, true); static void TestTryCatchFinallyUsingTryCatchHandler
()
{
9131 LocalContext env;
9132 v8::HandleScope scope(env->GetIsolate());
9133 v8::TryCatch try_catch(env->GetIsolate());
9134 CompileRun("try { throw ''; } catch (e) {}");
9135 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 9135, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
9136 CompileRun("try { throw ''; } finally {}");
9137 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 9137, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
9138 try_catch.Reset();
9139 CompileRun(
9140 "(function() {"
9141 "try { throw ''; } finally { return; }"
9142 "})()");
9143 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 9143, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
9144 CompileRun(
9145 "(function()"
9146 " { try { throw ''; } finally { throw 0; }"
9147 "})()");
9148 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 9148, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
9149}
9150
9151
9152void CEvaluate(const v8::FunctionCallbackInfo<v8::Value>& args) {
9153 v8::HandleScope scope(args.GetIsolate());
9154 CompileRun(args[0]
9155 ->ToString(args.GetIsolate()->GetCurrentContext())
9156 .ToLocalChecked());
9157}
9158
9159
9160TEST(TryCatchFinallyStoresMessageUsingTryCatchHandler)static void TestTryCatchFinallyStoresMessageUsingTryCatchHandler
(); CcTest register_test_TryCatchFinallyStoresMessageUsingTryCatchHandler
(TestTryCatchFinallyStoresMessageUsingTryCatchHandler, "../test/cctest/test-api.cc"
, "TryCatchFinallyStoresMessageUsingTryCatchHandler", __null,
true, true); static void TestTryCatchFinallyStoresMessageUsingTryCatchHandler
()
{
9161 v8::Isolate* isolate = CcTest::isolate();
9162 v8::HandleScope scope(isolate);
9163 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
9164 templ->Set(v8_str("CEvaluate"),
9165 v8::FunctionTemplate::New(isolate, CEvaluate));
9166 LocalContext context(0, templ);
9167 v8::TryCatch try_catch(isolate);
9168 CompileRun("try {"
9169 " CEvaluate('throw 1;');"
9170 "} finally {"
9171 "}");
9172 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 9172, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
9173 CHECK(!try_catch.Message().IsEmpty())do { if ((__builtin_expect(!!(!(!try_catch.Message().IsEmpty(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9173, "Check failed: %s."
, "!try_catch.Message().IsEmpty()"); } } while (0)
;
9174 String::Utf8Value exception_value(try_catch.Exception());
9175 CHECK_EQ(0, strcmp(*exception_value, "1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*exception_value, "1")), "0" " " "==" " " "strcmp(*exception_value, \"1\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 9175, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9176 try_catch.Reset();
9177 CompileRun("try {"
9178 " CEvaluate('throw 1;');"
9179 "} finally {"
9180 " throw 2;"
9181 "}");
9182 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 9182, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
9183 CHECK(!try_catch.Message().IsEmpty())do { if ((__builtin_expect(!!(!(!try_catch.Message().IsEmpty(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9183, "Check failed: %s."
, "!try_catch.Message().IsEmpty()"); } } while (0)
;
9184 String::Utf8Value finally_exception_value(try_catch.Exception());
9185 CHECK_EQ(0, strcmp(*finally_exception_value, "2"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*finally_exception_value, "2")), "0" " " "==" " " "strcmp(*finally_exception_value, \"2\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 9185, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9186}
9187
9188
9189// For use within the TestSecurityHandler() test.
9190static bool g_security_callback_result = false;
9191static bool SecurityTestCallback(Local<v8::Context> accessing_context,
9192 Local<v8::Object> accessed_object,
9193 Local<v8::Value> data) {
9194 printf("a\n");
9195 CHECK(!data.IsEmpty() && data->IsInt32())do { if ((__builtin_expect(!!(!(!data.IsEmpty() && data
->IsInt32())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9195, "Check failed: %s.", "!data.IsEmpty() && data->IsInt32()"
); } } while (0)
;
9196 CHECK_EQ(42, data->Int32Value(accessing_context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
data->Int32Value(accessing_context).FromJust()), "42" " " "=="
" " "data->Int32Value(accessing_context).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 9196, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
9197 return g_security_callback_result;
9198}
9199
9200
9201// SecurityHandler can't be run twice
9202TEST(SecurityHandler)static void TestSecurityHandler(); CcTest register_test_SecurityHandler
(TestSecurityHandler, "../test/cctest/test-api.cc", "SecurityHandler"
, __null, true, true); static void TestSecurityHandler()
{
9203 v8::Isolate* isolate = CcTest::isolate();
9204 v8::HandleScope scope0(isolate);
9205 v8::Local<v8::ObjectTemplate> global_template =
9206 v8::ObjectTemplate::New(isolate);
9207 global_template->SetAccessCheckCallback(SecurityTestCallback, v8_num(42));
9208 // Create an environment
9209 v8::Local<Context> context0 = Context::New(isolate, NULL__null, global_template);
9210 context0->Enter();
9211
9212 v8::Local<v8::Object> global0 = context0->Global();
9213 v8::Local<Script> script0 = v8_compile("foo = 111");
9214 script0->Run(context0).ToLocalChecked();
9215 CHECK(global0->Set(context0, v8_str("0"), v8_num(999)).FromJust())do { if ((__builtin_expect(!!(!(global0->Set(context0, v8_str
("0"), v8_num(999)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9215, "Check failed: %s.", "global0->Set(context0, v8_str(\"0\"), v8_num(999)).FromJust()"
); } } while (0)
;
9216 v8::Local<Value> foo0 =
9217 global0->Get(context0, v8_str("foo")).ToLocalChecked();
9218 CHECK_EQ(111, foo0->Int32Value(context0).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (111), (
foo0->Int32Value(context0).FromJust()), "111" " " "==" " "
"foo0->Int32Value(context0).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 9218, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
9219 v8::Local<Value> z0 = global0->Get(context0, v8_str("0")).ToLocalChecked();
9220 CHECK_EQ(999, z0->Int32Value(context0).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (999), (
z0->Int32Value(context0).FromJust()), "999" " " "==" " " "z0->Int32Value(context0).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9220, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9221
9222 // Create another environment, should fail security checks.
9223 v8::HandleScope scope1(isolate);
9224
9225 v8::Local<Context> context1 = Context::New(isolate, NULL__null, global_template);
9226 context1->Enter();
9227
9228 v8::Local<v8::Object> global1 = context1->Global();
9229 global1->Set(context1, v8_str("othercontext"), global0).FromJust();
9230 // This set will fail the security check.
9231 v8::Local<Script> script1 =
9232 v8_compile("othercontext.foo = 222; othercontext[0] = 888;");
9233 CHECK(script1->Run(context1).IsEmpty())do { if ((__builtin_expect(!!(!(script1->Run(context1).IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9233, "Check failed: %s."
, "script1->Run(context1).IsEmpty()"); } } while (0)
;
9234 g_security_callback_result = true;
9235 // This read will pass the security check.
9236 v8::Local<Value> foo1 =
9237 global0->Get(context1, v8_str("foo")).ToLocalChecked();
9238 CHECK_EQ(111, foo1->Int32Value(context0).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (111), (
foo1->Int32Value(context0).FromJust()), "111" " " "==" " "
"foo1->Int32Value(context0).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 9238, "Check failed: %s.", _msg->c_str()); delete _msg; }
} while (0)
;
9239 // This read will pass the security check.
9240 v8::Local<Value> z1 = global0->Get(context1, v8_str("0")).ToLocalChecked();
9241 CHECK_EQ(999, z1->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (999), (
z1->Int32Value(context1).FromJust()), "999" " " "==" " " "z1->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9241, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9242
9243 // Create another environment, should pass security checks.
9244 {
9245 v8::HandleScope scope2(isolate);
9246 LocalContext context2;
9247 v8::Local<v8::Object> global2 = context2->Global();
9248 CHECK(global2->Set(context2.local(), v8_str("othercontext"), global0)do { if ((__builtin_expect(!!(!(global2->Set(context2.local
(), v8_str("othercontext"), global0) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9249, "Check failed: %s.", "global2->Set(context2.local(), v8_str(\"othercontext\"), global0) .FromJust()"
); } } while (0)
9249 .FromJust())do { if ((__builtin_expect(!!(!(global2->Set(context2.local
(), v8_str("othercontext"), global0) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9249, "Check failed: %s.", "global2->Set(context2.local(), v8_str(\"othercontext\"), global0) .FromJust()"
); } } while (0)
;
9250 v8::Local<Script> script2 =
9251 v8_compile("othercontext.foo = 333; othercontext[0] = 888;");
9252 script2->Run(context2.local()).ToLocalChecked();
9253 v8::Local<Value> foo2 =
9254 global0->Get(context2.local(), v8_str("foo")).ToLocalChecked();
9255 CHECK_EQ(333, foo2->Int32Value(context2.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (333), (
foo2->Int32Value(context2.local()).FromJust()), "333" " " "=="
" " "foo2->Int32Value(context2.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 9255, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
9256 v8::Local<Value> z2 =
9257 global0->Get(context2.local(), v8_str("0")).ToLocalChecked();
9258 CHECK_EQ(888, z2->Int32Value(context2.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (888), (
z2->Int32Value(context2.local()).FromJust()), "888" " " "=="
" " "z2->Int32Value(context2.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 9258, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
9259 }
9260
9261 context1->Exit();
9262 context0->Exit();
9263}
9264
9265
9266THREADED_TEST(SecurityChecks)static void TestSecurityChecks(); RegisterThreadedTest register_SecurityChecks
(TestSecurityChecks, "SecurityChecks"); static void TestSecurityChecks
(); CcTest register_test_SecurityChecks(TestSecurityChecks, "../test/cctest/test-api.cc"
, "SecurityChecks", __null, true, true); static void TestSecurityChecks
()
{
9267 LocalContext env1;
9268 v8::HandleScope handle_scope(env1->GetIsolate());
9269 v8::Local<Context> env2 = Context::New(env1->GetIsolate());
9270
9271 Local<Value> foo = v8_str("foo");
9272 Local<Value> bar = v8_str("bar");
9273
9274 // Set to the same domain.
9275 env1->SetSecurityToken(foo);
9276
9277 // Create a function in env1.
9278 CompileRun("spy=function(){return spy;}");
9279 Local<Value> spy =
9280 env1->Global()->Get(env1.local(), v8_str("spy")).ToLocalChecked();
9281 CHECK(spy->IsFunction())do { if ((__builtin_expect(!!(!(spy->IsFunction())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9281, "Check failed: %s."
, "spy->IsFunction()"); } } while (0)
;
9282
9283 // Create another function accessing global objects.
9284 CompileRun("spy2=function(){return new this.Array();}");
9285 Local<Value> spy2 =
9286 env1->Global()->Get(env1.local(), v8_str("spy2")).ToLocalChecked();
9287 CHECK(spy2->IsFunction())do { if ((__builtin_expect(!!(!(spy2->IsFunction())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 9287, "Check failed: %s."
, "spy2->IsFunction()"); } } while (0)
;
9288
9289 // Switch to env2 in the same domain and invoke spy on env2.
9290 {
9291 env2->SetSecurityToken(foo);
9292 // Enter env2
9293 Context::Scope scope_env2(env2);
9294 Local<Value> result = Function::Cast(*spy)
9295 ->Call(env2, env2->Global(), 0, NULL__null)
9296 .ToLocalChecked();
9297 CHECK(result->IsFunction())do { if ((__builtin_expect(!!(!(result->IsFunction())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 9297, "Check failed: %s."
, "result->IsFunction()"); } } while (0)
;
9298 }
9299
9300 {
9301 env2->SetSecurityToken(bar);
9302 Context::Scope scope_env2(env2);
9303
9304 // Call cross_domain_call, it should throw an exception
9305 v8::TryCatch try_catch(env1->GetIsolate());
9306 CHECK(Function::Cast(*spy2)->Call(env2, env2->Global(), 0, NULL).IsEmpty())do { if ((__builtin_expect(!!(!(Function::Cast(*spy2)->Call
(env2, env2->Global(), 0, __null).IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9306, "Check failed: %s.", "Function::Cast(*spy2)->Call(env2, env2->Global(), 0, NULL).IsEmpty()"
); } } while (0)
;
9307 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 9307, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
9308 }
9309}
9310
9311
9312// Regression test case for issue 1183439.
9313THREADED_TEST(SecurityChecksForPrototypeChain)static void TestSecurityChecksForPrototypeChain(); RegisterThreadedTest
register_SecurityChecksForPrototypeChain(TestSecurityChecksForPrototypeChain
, "SecurityChecksForPrototypeChain"); static void TestSecurityChecksForPrototypeChain
(); CcTest register_test_SecurityChecksForPrototypeChain(TestSecurityChecksForPrototypeChain
, "../test/cctest/test-api.cc", "SecurityChecksForPrototypeChain"
, __null, true, true); static void TestSecurityChecksForPrototypeChain
()
{
9314 LocalContext current;
9315 v8::HandleScope scope(current->GetIsolate());
9316 v8::Local<Context> other = Context::New(current->GetIsolate());
9317
9318 // Change context to be able to get to the Object function in the
9319 // other context without hitting the security checks.
9320 v8::Local<Value> other_object;
9321 { Context::Scope scope(other);
9322 other_object =
9323 other->Global()->Get(other, v8_str("Object")).ToLocalChecked();
9324 CHECK(other->Global()->Set(other, v8_num(42), v8_num(87)).FromJust())do { if ((__builtin_expect(!!(!(other->Global()->Set(other
, v8_num(42), v8_num(87)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9324, "Check failed: %s.", "other->Global()->Set(other, v8_num(42), v8_num(87)).FromJust()"
); } } while (0)
;
9325 }
9326
9327 CHECK(current->Global()do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9329, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
9328 ->Set(current.local(), v8_str("other"), other->Global())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9329, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
9329 .FromJust())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9329, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
;
9330 CHECK(v8_compile("other")do { if ((__builtin_expect(!!(!(v8_compile("other") ->Run(
current.local()) .ToLocalChecked() ->Equals(current.local(
), other->Global()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9334, "Check failed: %s.", "v8_compile(\"other\") ->Run(current.local()) .ToLocalChecked() ->Equals(current.local(), other->Global()) .FromJust()"
); } } while (0)
9331 ->Run(current.local())do { if ((__builtin_expect(!!(!(v8_compile("other") ->Run(
current.local()) .ToLocalChecked() ->Equals(current.local(
), other->Global()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9334, "Check failed: %s.", "v8_compile(\"other\") ->Run(current.local()) .ToLocalChecked() ->Equals(current.local(), other->Global()) .FromJust()"
); } } while (0)
9332 .ToLocalChecked()do { if ((__builtin_expect(!!(!(v8_compile("other") ->Run(
current.local()) .ToLocalChecked() ->Equals(current.local(
), other->Global()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9334, "Check failed: %s.", "v8_compile(\"other\") ->Run(current.local()) .ToLocalChecked() ->Equals(current.local(), other->Global()) .FromJust()"
); } } while (0)
9333 ->Equals(current.local(), other->Global())do { if ((__builtin_expect(!!(!(v8_compile("other") ->Run(
current.local()) .ToLocalChecked() ->Equals(current.local(
), other->Global()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9334, "Check failed: %s.", "v8_compile(\"other\") ->Run(current.local()) .ToLocalChecked() ->Equals(current.local(), other->Global()) .FromJust()"
); } } while (0)
9334 .FromJust())do { if ((__builtin_expect(!!(!(v8_compile("other") ->Run(
current.local()) .ToLocalChecked() ->Equals(current.local(
), other->Global()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9334, "Check failed: %s.", "v8_compile(\"other\") ->Run(current.local()) .ToLocalChecked() ->Equals(current.local(), other->Global()) .FromJust()"
); } } while (0)
;
9335
9336 // Make sure the security check fails here and we get an undefined
9337 // result instead of getting the Object function. Repeat in a loop
9338 // to make sure to exercise the IC code.
9339 v8::Local<Script> access_other0 = v8_compile("other.Object");
9340 v8::Local<Script> access_other1 = v8_compile("other[42]");
9341 for (int i = 0; i < 5; i++) {
9342 CHECK(access_other0->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(access_other0->Run(current
.local()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9342, "Check failed: %s.", "access_other0->Run(current.local()).IsEmpty()"
); } } while (0)
;
9343 CHECK(access_other1->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(access_other1->Run(current
.local()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9343, "Check failed: %s.", "access_other1->Run(current.local()).IsEmpty()"
); } } while (0)
;
9344 }
9345
9346 // Create an object that has 'other' in its prototype chain and make
9347 // sure we cannot access the Object function indirectly through
9348 // that. Repeat in a loop to make sure to exercise the IC code.
9349 v8_compile(
9350 "function F() { };"
9351 "F.prototype = other;"
9352 "var f = new F();")
9353 ->Run(current.local())
9354 .ToLocalChecked();
9355 v8::Local<Script> access_f0 = v8_compile("f.Object");
9356 v8::Local<Script> access_f1 = v8_compile("f[42]");
9357 for (int j = 0; j < 5; j++) {
9358 CHECK(access_f0->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(access_f0->Run(current.local
()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9358, "Check failed: %s.", "access_f0->Run(current.local()).IsEmpty()"
); } } while (0)
;
9359 CHECK(access_f1->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(access_f1->Run(current.local
()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9359, "Check failed: %s.", "access_f1->Run(current.local()).IsEmpty()"
); } } while (0)
;
9360 }
9361
9362 // Now it gets hairy: Set the prototype for the other global object
9363 // to be the current global object. The prototype chain for 'f' now
9364 // goes through 'other' but ends up in the current global object.
9365 { Context::Scope scope(other);
9366 CHECK(other->Global()do { if ((__builtin_expect(!!(!(other->Global() ->Set(other
, v8_str("__proto__"), current->Global()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9368, "Check failed: %s."
, "other->Global() ->Set(other, v8_str(\"__proto__\"), current->Global()) .FromJust()"
); } } while (0)
9367 ->Set(other, v8_str("__proto__"), current->Global())do { if ((__builtin_expect(!!(!(other->Global() ->Set(other
, v8_str("__proto__"), current->Global()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9368, "Check failed: %s."
, "other->Global() ->Set(other, v8_str(\"__proto__\"), current->Global()) .FromJust()"
); } } while (0)
9368 .FromJust())do { if ((__builtin_expect(!!(!(other->Global() ->Set(other
, v8_str("__proto__"), current->Global()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9368, "Check failed: %s."
, "other->Global() ->Set(other, v8_str(\"__proto__\"), current->Global()) .FromJust()"
); } } while (0)
;
9369 }
9370 // Set a named and an index property on the current global
9371 // object. To force the lookup to go through the other global object,
9372 // the properties must not exist in the other global object.
9373 CHECK(current->Global()do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("foo"), v8_num(100)) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9375, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"foo\"), v8_num(100)) .FromJust()"
); } } while (0)
9374 ->Set(current.local(), v8_str("foo"), v8_num(100))do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("foo"), v8_num(100)) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9375, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"foo\"), v8_num(100)) .FromJust()"
); } } while (0)
9375 .FromJust())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("foo"), v8_num(100)) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9375, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"foo\"), v8_num(100)) .FromJust()"
); } } while (0)
;
9376 CHECK(current->Global()do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_num(99), v8_num(101)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 9378, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_num(99), v8_num(101)) .FromJust()"
); } } while (0)
9377 ->Set(current.local(), v8_num(99), v8_num(101))do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_num(99), v8_num(101)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 9378, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_num(99), v8_num(101)) .FromJust()"
); } } while (0)
9378 .FromJust())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_num(99), v8_num(101)) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 9378, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_num(99), v8_num(101)) .FromJust()"
); } } while (0)
;
9379 // Try to read the properties from f and make sure that the access
9380 // gets stopped by the security checks on the other global object.
9381 Local<Script> access_f2 = v8_compile("f.foo");
9382 Local<Script> access_f3 = v8_compile("f[99]");
9383 for (int k = 0; k < 5; k++) {
9384 CHECK(access_f2->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(access_f2->Run(current.local
()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9384, "Check failed: %s.", "access_f2->Run(current.local()).IsEmpty()"
); } } while (0)
;
9385 CHECK(access_f3->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(access_f3->Run(current.local
()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9385, "Check failed: %s.", "access_f3->Run(current.local()).IsEmpty()"
); } } while (0)
;
9386 }
9387}
9388
9389
9390static bool security_check_with_gc_called;
9391
9392static bool SecurityTestCallbackWithGC(Local<v8::Context> accessing_context,
9393 Local<v8::Object> accessed_object,
9394 Local<v8::Value> data) {
9395 CcTest::heap()->CollectAllGarbage();
9396 security_check_with_gc_called = true;
9397 return true;
9398}
9399
9400
9401TEST(SecurityTestGCAllowed)static void TestSecurityTestGCAllowed(); CcTest register_test_SecurityTestGCAllowed
(TestSecurityTestGCAllowed, "../test/cctest/test-api.cc", "SecurityTestGCAllowed"
, __null, true, true); static void TestSecurityTestGCAllowed(
)
{
9402 v8::Isolate* isolate = CcTest::isolate();
9403 v8::HandleScope handle_scope(isolate);
9404 v8::Local<v8::ObjectTemplate> object_template =
9405 v8::ObjectTemplate::New(isolate);
9406 object_template->SetAccessCheckCallback(SecurityTestCallbackWithGC);
9407
9408 v8::Local<Context> context = Context::New(isolate);
9409 v8::Context::Scope context_scope(context);
9410
9411 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("obj"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9414, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"obj\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
9412 ->Set(context, v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("obj"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9414, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"obj\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
9413 object_template->NewInstance(context).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("obj"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9414, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"obj\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
9414 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("obj"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9414, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"obj\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9415
9416 security_check_with_gc_called = false;
9417 CompileRun("obj[0] = new String(1002);");
9418 CHECK(security_check_with_gc_called)do { if ((__builtin_expect(!!(!(security_check_with_gc_called
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9418, "Check failed: %s."
, "security_check_with_gc_called"); } } while (0)
;
9419
9420 security_check_with_gc_called = false;
9421 CHECK(CompileRun("obj[0]")do { if ((__builtin_expect(!!(!(CompileRun("obj[0]") ->ToString
(context) .ToLocalChecked() ->Equals(context, v8_str("1002"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9425, "Check failed: %s.", "CompileRun(\"obj[0]\") ->ToString(context) .ToLocalChecked() ->Equals(context, v8_str(\"1002\")) .FromJust()"
); } } while (0)
9422 ->ToString(context)do { if ((__builtin_expect(!!(!(CompileRun("obj[0]") ->ToString
(context) .ToLocalChecked() ->Equals(context, v8_str("1002"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9425, "Check failed: %s.", "CompileRun(\"obj[0]\") ->ToString(context) .ToLocalChecked() ->Equals(context, v8_str(\"1002\")) .FromJust()"
); } } while (0)
9423 .ToLocalChecked()do { if ((__builtin_expect(!!(!(CompileRun("obj[0]") ->ToString
(context) .ToLocalChecked() ->Equals(context, v8_str("1002"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9425, "Check failed: %s.", "CompileRun(\"obj[0]\") ->ToString(context) .ToLocalChecked() ->Equals(context, v8_str(\"1002\")) .FromJust()"
); } } while (0)
9424 ->Equals(context, v8_str("1002"))do { if ((__builtin_expect(!!(!(CompileRun("obj[0]") ->ToString
(context) .ToLocalChecked() ->Equals(context, v8_str("1002"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9425, "Check failed: %s.", "CompileRun(\"obj[0]\") ->ToString(context) .ToLocalChecked() ->Equals(context, v8_str(\"1002\")) .FromJust()"
); } } while (0)
9425 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("obj[0]") ->ToString
(context) .ToLocalChecked() ->Equals(context, v8_str("1002"
)) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9425, "Check failed: %s.", "CompileRun(\"obj[0]\") ->ToString(context) .ToLocalChecked() ->Equals(context, v8_str(\"1002\")) .FromJust()"
); } } while (0)
;
9426 CHECK(security_check_with_gc_called)do { if ((__builtin_expect(!!(!(security_check_with_gc_called
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9426, "Check failed: %s."
, "security_check_with_gc_called"); } } while (0)
;
9427}
9428
9429
9430THREADED_TEST(CrossDomainDelete)static void TestCrossDomainDelete(); RegisterThreadedTest register_CrossDomainDelete
(TestCrossDomainDelete, "CrossDomainDelete"); static void TestCrossDomainDelete
(); CcTest register_test_CrossDomainDelete(TestCrossDomainDelete
, "../test/cctest/test-api.cc", "CrossDomainDelete", __null, true
, true); static void TestCrossDomainDelete()
{
9431 LocalContext env1;
9432 v8::HandleScope handle_scope(env1->GetIsolate());
9433 v8::Local<Context> env2 = Context::New(env1->GetIsolate());
9434
9435 Local<Value> foo = v8_str("foo");
9436 Local<Value> bar = v8_str("bar");
9437
9438 // Set to the same domain.
9439 env1->SetSecurityToken(foo);
9440 env2->SetSecurityToken(foo);
9441
9442 CHECK(do { if ((__builtin_expect(!!(!(env1->Global()->Set(env1
.local(), v8_str("prop"), v8_num(3)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9443, "Check failed: %s.", "env1->Global()->Set(env1.local(), v8_str(\"prop\"), v8_num(3)).FromJust()"
); } } while (0)
9443 env1->Global()->Set(env1.local(), v8_str("prop"), v8_num(3)).FromJust())do { if ((__builtin_expect(!!(!(env1->Global()->Set(env1
.local(), v8_str("prop"), v8_num(3)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9443, "Check failed: %s.", "env1->Global()->Set(env1.local(), v8_str(\"prop\"), v8_num(3)).FromJust()"
); } } while (0)
;
9444 CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust())do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
, v8_str("env1"), env1->Global()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9444, "Check failed: %s.", "env2->Global()->Set(env2, v8_str(\"env1\"), env1->Global()).FromJust()"
); } } while (0)
;
9445
9446 // Change env2 to a different domain and delete env1.prop.
9447 env2->SetSecurityToken(bar);
9448 {
9449 Context::Scope scope_env2(env2);
9450 Local<Value> result =
9451 CompileRun("delete env1.prop");
9452 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9452, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
9453 }
9454
9455 // Check that env1.prop still exists.
9456 Local<Value> v =
9457 env1->Global()->Get(env1.local(), v8_str("prop")).ToLocalChecked();
9458 CHECK(v->IsNumber())do { if ((__builtin_expect(!!(!(v->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9458, "Check failed: %s.", "v->IsNumber()"
); } } while (0)
;
9459 CHECK_EQ(3, v->Int32Value(env1.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (v
->Int32Value(env1.local()).FromJust()), "3" " " "==" " " "v->Int32Value(env1.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9459, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9460}
9461
9462
9463THREADED_TEST(CrossDomainPropertyIsEnumerable)static void TestCrossDomainPropertyIsEnumerable(); RegisterThreadedTest
register_CrossDomainPropertyIsEnumerable(TestCrossDomainPropertyIsEnumerable
, "CrossDomainPropertyIsEnumerable"); static void TestCrossDomainPropertyIsEnumerable
(); CcTest register_test_CrossDomainPropertyIsEnumerable(TestCrossDomainPropertyIsEnumerable
, "../test/cctest/test-api.cc", "CrossDomainPropertyIsEnumerable"
, __null, true, true); static void TestCrossDomainPropertyIsEnumerable
()
{
9464 LocalContext env1;
9465 v8::HandleScope handle_scope(env1->GetIsolate());
9466 v8::Local<Context> env2 = Context::New(env1->GetIsolate());
9467
9468 Local<Value> foo = v8_str("foo");
9469 Local<Value> bar = v8_str("bar");
9470
9471 // Set to the same domain.
9472 env1->SetSecurityToken(foo);
9473 env2->SetSecurityToken(foo);
9474
9475 CHECK(do { if ((__builtin_expect(!!(!(env1->Global()->Set(env1
.local(), v8_str("prop"), v8_num(3)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9476, "Check failed: %s.", "env1->Global()->Set(env1.local(), v8_str(\"prop\"), v8_num(3)).FromJust()"
); } } while (0)
9476 env1->Global()->Set(env1.local(), v8_str("prop"), v8_num(3)).FromJust())do { if ((__builtin_expect(!!(!(env1->Global()->Set(env1
.local(), v8_str("prop"), v8_num(3)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9476, "Check failed: %s.", "env1->Global()->Set(env1.local(), v8_str(\"prop\"), v8_num(3)).FromJust()"
); } } while (0)
;
9477 CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust())do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
, v8_str("env1"), env1->Global()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9477, "Check failed: %s.", "env2->Global()->Set(env2, v8_str(\"env1\"), env1->Global()).FromJust()"
); } } while (0)
;
9478
9479 // env1.prop is enumerable in env2.
9480 Local<String> test = v8_str("propertyIsEnumerable.call(env1, 'prop')");
9481 {
9482 Context::Scope scope_env2(env2);
9483 Local<Value> result = CompileRun(test);
9484 CHECK(result->IsTrue())do { if ((__builtin_expect(!!(!(result->IsTrue())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9484, "Check failed: %s."
, "result->IsTrue()"); } } while (0)
;
9485 }
9486
9487 // Change env2 to a different domain and test again.
9488 env2->SetSecurityToken(bar);
9489 {
9490 Context::Scope scope_env2(env2);
9491 Local<Value> result = CompileRun(test);
9492 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9492, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
9493 }
9494}
9495
9496
9497THREADED_TEST(CrossDomainFor)static void TestCrossDomainFor(); RegisterThreadedTest register_CrossDomainFor
(TestCrossDomainFor, "CrossDomainFor"); static void TestCrossDomainFor
(); CcTest register_test_CrossDomainFor(TestCrossDomainFor, "../test/cctest/test-api.cc"
, "CrossDomainFor", __null, true, true); static void TestCrossDomainFor
()
{
9498 LocalContext env1;
9499 v8::HandleScope handle_scope(env1->GetIsolate());
9500 v8::Local<Context> env2 = Context::New(env1->GetIsolate());
9501
9502 Local<Value> foo = v8_str("foo");
9503 Local<Value> bar = v8_str("bar");
9504
9505 // Set to the same domain.
9506 env1->SetSecurityToken(foo);
9507 env2->SetSecurityToken(foo);
9508
9509 CHECK(do { if ((__builtin_expect(!!(!(env1->Global()->Set(env1
.local(), v8_str("prop"), v8_num(3)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9510, "Check failed: %s.", "env1->Global()->Set(env1.local(), v8_str(\"prop\"), v8_num(3)).FromJust()"
); } } while (0)
9510 env1->Global()->Set(env1.local(), v8_str("prop"), v8_num(3)).FromJust())do { if ((__builtin_expect(!!(!(env1->Global()->Set(env1
.local(), v8_str("prop"), v8_num(3)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9510, "Check failed: %s.", "env1->Global()->Set(env1.local(), v8_str(\"prop\"), v8_num(3)).FromJust()"
); } } while (0)
;
9511 CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust())do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
, v8_str("env1"), env1->Global()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9511, "Check failed: %s.", "env2->Global()->Set(env2, v8_str(\"env1\"), env1->Global()).FromJust()"
); } } while (0)
;
9512
9513 // Change env2 to a different domain and set env1's global object
9514 // as the __proto__ of an object in env2 and enumerate properties
9515 // in for-in. It shouldn't enumerate properties on env1's global
9516 // object. It shouldn't throw either, just silently ignore them.
9517 env2->SetSecurityToken(bar);
9518 {
9519 Context::Scope scope_env2(env2);
9520 Local<Value> result = CompileRun(
9521 "(function() {"
9522 " try {"
9523 " for (var p in env1) {"
9524 " if (p == 'prop') return false;"
9525 " }"
9526 " return true;"
9527 " } catch (e) {"
9528 " return false;"
9529 " }"
9530 "})()");
9531 CHECK(result->IsTrue())do { if ((__builtin_expect(!!(!(result->IsTrue())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9531, "Check failed: %s."
, "result->IsTrue()"); } } while (0)
;
9532 }
9533}
9534
9535
9536THREADED_TEST(CrossDomainForInOnPrototype)static void TestCrossDomainForInOnPrototype(); RegisterThreadedTest
register_CrossDomainForInOnPrototype(TestCrossDomainForInOnPrototype
, "CrossDomainForInOnPrototype"); static void TestCrossDomainForInOnPrototype
(); CcTest register_test_CrossDomainForInOnPrototype(TestCrossDomainForInOnPrototype
, "../test/cctest/test-api.cc", "CrossDomainForInOnPrototype"
, __null, true, true); static void TestCrossDomainForInOnPrototype
()
{
9537 LocalContext env1;
9538 v8::HandleScope handle_scope(env1->GetIsolate());
9539 v8::Local<Context> env2 = Context::New(env1->GetIsolate());
9540
9541 Local<Value> foo = v8_str("foo");
9542 Local<Value> bar = v8_str("bar");
9543
9544 // Set to the same domain.
9545 env1->SetSecurityToken(foo);
9546 env2->SetSecurityToken(foo);
9547
9548 CHECK(do { if ((__builtin_expect(!!(!(env1->Global()->Set(env1
.local(), v8_str("prop"), v8_num(3)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9549, "Check failed: %s.", "env1->Global()->Set(env1.local(), v8_str(\"prop\"), v8_num(3)).FromJust()"
); } } while (0)
9549 env1->Global()->Set(env1.local(), v8_str("prop"), v8_num(3)).FromJust())do { if ((__builtin_expect(!!(!(env1->Global()->Set(env1
.local(), v8_str("prop"), v8_num(3)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9549, "Check failed: %s.", "env1->Global()->Set(env1.local(), v8_str(\"prop\"), v8_num(3)).FromJust()"
); } } while (0)
;
9550 CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust())do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
, v8_str("env1"), env1->Global()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9550, "Check failed: %s.", "env2->Global()->Set(env2, v8_str(\"env1\"), env1->Global()).FromJust()"
); } } while (0)
;
9551
9552 // Change env2 to a different domain and set env1's global object
9553 // as the __proto__ of an object in env2 and enumerate properties
9554 // in for-in. It shouldn't enumerate properties on env1's global
9555 // object.
9556 env2->SetSecurityToken(bar);
9557 {
9558 Context::Scope scope_env2(env2);
9559 Local<Value> result = CompileRun(
9560 "(function() {"
9561 " var obj = { '__proto__': env1 };"
9562 " try {"
9563 " for (var p in obj) {"
9564 " if (p == 'prop') return false;"
9565 " }"
9566 " return true;"
9567 " } catch (e) {"
9568 " return false;"
9569 " }"
9570 "})()");
9571 CHECK(result->IsTrue())do { if ((__builtin_expect(!!(!(result->IsTrue())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9571, "Check failed: %s."
, "result->IsTrue()"); } } while (0)
;
9572 }
9573}
9574
9575
9576TEST(ContextDetachGlobal)static void TestContextDetachGlobal(); CcTest register_test_ContextDetachGlobal
(TestContextDetachGlobal, "../test/cctest/test-api.cc", "ContextDetachGlobal"
, __null, true, true); static void TestContextDetachGlobal()
{
9577 LocalContext env1;
9578 v8::HandleScope handle_scope(env1->GetIsolate());
9579 v8::Local<Context> env2 = Context::New(env1->GetIsolate());
9580
9581
9582 Local<Value> foo = v8_str("foo");
9583
9584 // Set to the same domain.
9585 env1->SetSecurityToken(foo);
9586 env2->SetSecurityToken(foo);
9587
9588 // Enter env2
9589 env2->Enter();
9590
9591 // Create a function in env2 and add a reference to it in env1.
9592 Local<v8::Object> global2 = env2->Global();
9593 CHECK(global2->Set(env2, v8_str("prop"),do { if ((__builtin_expect(!!(!(global2->Set(env2, v8_str(
"prop"), v8::Integer::New(env2->GetIsolate(), 1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9595, "Check failed: %s."
, "global2->Set(env2, v8_str(\"prop\"), v8::Integer::New(env2->GetIsolate(), 1)) .FromJust()"
); } } while (0)
9594 v8::Integer::New(env2->GetIsolate(), 1))do { if ((__builtin_expect(!!(!(global2->Set(env2, v8_str(
"prop"), v8::Integer::New(env2->GetIsolate(), 1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9595, "Check failed: %s."
, "global2->Set(env2, v8_str(\"prop\"), v8::Integer::New(env2->GetIsolate(), 1)) .FromJust()"
); } } while (0)
9595 .FromJust())do { if ((__builtin_expect(!!(!(global2->Set(env2, v8_str(
"prop"), v8::Integer::New(env2->GetIsolate(), 1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9595, "Check failed: %s."
, "global2->Set(env2, v8_str(\"prop\"), v8::Integer::New(env2->GetIsolate(), 1)) .FromJust()"
); } } while (0)
;
9596 CompileRun("function getProp() {return prop;}");
9597
9598 CHECK(env1->Global()do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("getProp"), global2->Get(env2, v8_str("getProp"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9601, "Check failed: %s.", "env1->Global() ->Set(env1.local(), v8_str(\"getProp\"), global2->Get(env2, v8_str(\"getProp\")).ToLocalChecked()) .FromJust()"
); } } while (0)
9599 ->Set(env1.local(), v8_str("getProp"),do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("getProp"), global2->Get(env2, v8_str("getProp"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9601, "Check failed: %s.", "env1->Global() ->Set(env1.local(), v8_str(\"getProp\"), global2->Get(env2, v8_str(\"getProp\")).ToLocalChecked()) .FromJust()"
); } } while (0)
9600 global2->Get(env2, v8_str("getProp")).ToLocalChecked())do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("getProp"), global2->Get(env2, v8_str("getProp"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9601, "Check failed: %s.", "env1->Global() ->Set(env1.local(), v8_str(\"getProp\"), global2->Get(env2, v8_str(\"getProp\")).ToLocalChecked()) .FromJust()"
); } } while (0)
9601 .FromJust())do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("getProp"), global2->Get(env2, v8_str("getProp"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9601, "Check failed: %s.", "env1->Global() ->Set(env1.local(), v8_str(\"getProp\"), global2->Get(env2, v8_str(\"getProp\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9602
9603 // Detach env2's global, and reuse the global object of env2
9604 env2->Exit();
9605 env2->DetachGlobal();
9606
9607 v8::Local<Context> env3 = Context::New(
9608 env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(), global2);
9609 env3->SetSecurityToken(v8_str("bar"));
9610
9611 env3->Enter();
9612 Local<v8::Object> global3 = env3->Global();
9613 CHECK(global2->Equals(env3, global3).FromJust())do { if ((__builtin_expect(!!(!(global2->Equals(env3, global3
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
9613, "Check failed: %s.", "global2->Equals(env3, global3).FromJust()"
); } } while (0)
;
9614 CHECK(global3->Get(env3, v8_str("prop")).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(global3->Get(env3, v8_str(
"prop")).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9614, "Check failed: %s.", "global3->Get(env3, v8_str(\"prop\")).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
9615 CHECK(global3->Get(env3, v8_str("getProp")).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(global3->Get(env3, v8_str(
"getProp")).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9615, "Check failed: %s.", "global3->Get(env3, v8_str(\"getProp\")).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
9616 CHECK(global3->Set(env3, v8_str("prop"),do { if ((__builtin_expect(!!(!(global3->Set(env3, v8_str(
"prop"), v8::Integer::New(env3->GetIsolate(), -1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9618, "Check failed: %s."
, "global3->Set(env3, v8_str(\"prop\"), v8::Integer::New(env3->GetIsolate(), -1)) .FromJust()"
); } } while (0)
9617 v8::Integer::New(env3->GetIsolate(), -1))do { if ((__builtin_expect(!!(!(global3->Set(env3, v8_str(
"prop"), v8::Integer::New(env3->GetIsolate(), -1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9618, "Check failed: %s."
, "global3->Set(env3, v8_str(\"prop\"), v8::Integer::New(env3->GetIsolate(), -1)) .FromJust()"
); } } while (0)
9618 .FromJust())do { if ((__builtin_expect(!!(!(global3->Set(env3, v8_str(
"prop"), v8::Integer::New(env3->GetIsolate(), -1)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9618, "Check failed: %s."
, "global3->Set(env3, v8_str(\"prop\"), v8::Integer::New(env3->GetIsolate(), -1)) .FromJust()"
); } } while (0)
;
9619 CHECK(global3->Set(env3, v8_str("prop2"),do { if ((__builtin_expect(!!(!(global3->Set(env3, v8_str(
"prop2"), v8::Integer::New(env3->GetIsolate(), 2)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9621, "Check failed: %s."
, "global3->Set(env3, v8_str(\"prop2\"), v8::Integer::New(env3->GetIsolate(), 2)) .FromJust()"
); } } while (0)
9620 v8::Integer::New(env3->GetIsolate(), 2))do { if ((__builtin_expect(!!(!(global3->Set(env3, v8_str(
"prop2"), v8::Integer::New(env3->GetIsolate(), 2)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9621, "Check failed: %s."
, "global3->Set(env3, v8_str(\"prop2\"), v8::Integer::New(env3->GetIsolate(), 2)) .FromJust()"
); } } while (0)
9621 .FromJust())do { if ((__builtin_expect(!!(!(global3->Set(env3, v8_str(
"prop2"), v8::Integer::New(env3->GetIsolate(), 2)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9621, "Check failed: %s."
, "global3->Set(env3, v8_str(\"prop2\"), v8::Integer::New(env3->GetIsolate(), 2)) .FromJust()"
); } } while (0)
;
9622 env3->Exit();
9623
9624 // Call getProp in env1, and it should return the value 1
9625 {
9626 Local<v8::Object> global1 = env1->Global();
9627 Local<Value> get_prop =
9628 global1->Get(env1.local(), v8_str("getProp")).ToLocalChecked();
9629 CHECK(get_prop->IsFunction())do { if ((__builtin_expect(!!(!(get_prop->IsFunction())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9629, "Check failed: %s."
, "get_prop->IsFunction()"); } } while (0)
;
9630 v8::TryCatch try_catch(env1->GetIsolate());
9631 Local<Value> r = Function::Cast(*get_prop)
9632 ->Call(env1.local(), global1, 0, NULL__null)
9633 .ToLocalChecked();
9634 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 9634, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
9635 CHECK_EQ(1, r->Int32Value(env1.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (r
->Int32Value(env1.local()).FromJust()), "1" " " "==" " " "r->Int32Value(env1.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9635, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9636 }
9637
9638 // Check that env3 is not accessible from env1
9639 {
9640 v8::MaybeLocal<Value> r = global3->Get(env1.local(), v8_str("prop2"));
9641 CHECK(r.IsEmpty())do { if ((__builtin_expect(!!(!(r.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9641, "Check failed: %s.", "r.IsEmpty()"
); } } while (0)
;
9642 }
9643}
9644
9645
9646TEST(DetachGlobal)static void TestDetachGlobal(); CcTest register_test_DetachGlobal
(TestDetachGlobal, "../test/cctest/test-api.cc", "DetachGlobal"
, __null, true, true); static void TestDetachGlobal()
{
9647 LocalContext env1;
9648 v8::HandleScope scope(env1->GetIsolate());
9649
9650 // Create second environment.
9651 v8::Local<Context> env2 = Context::New(env1->GetIsolate());
9652
9653 Local<Value> foo = v8_str("foo");
9654
9655 // Set same security token for env1 and env2.
9656 env1->SetSecurityToken(foo);
9657 env2->SetSecurityToken(foo);
9658
9659 // Create a property on the global object in env2.
9660 {
9661 v8::Context::Scope scope(env2);
9662 CHECK(env2->Global()do { if ((__builtin_expect(!!(!(env2->Global() ->Set(env2
, v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9664
, "Check failed: %s.", "env2->Global() ->Set(env2, v8_str(\"p\"), v8::Integer::New(env2->GetIsolate(), 42)) .FromJust()"
); } } while (0)
9663 ->Set(env2, v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42))do { if ((__builtin_expect(!!(!(env2->Global() ->Set(env2
, v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9664
, "Check failed: %s.", "env2->Global() ->Set(env2, v8_str(\"p\"), v8::Integer::New(env2->GetIsolate(), 42)) .FromJust()"
); } } while (0)
9664 .FromJust())do { if ((__builtin_expect(!!(!(env2->Global() ->Set(env2
, v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9664
, "Check failed: %s.", "env2->Global() ->Set(env2, v8_str(\"p\"), v8::Integer::New(env2->GetIsolate(), 42)) .FromJust()"
); } } while (0)
;
9665 }
9666
9667 // Create a reference to env2 global from env1 global.
9668 CHECK(env1->Global()do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("other"), env2->Global()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9670, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"other\"), env2->Global()) .FromJust()"
); } } while (0)
9669 ->Set(env1.local(), v8_str("other"), env2->Global())do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("other"), env2->Global()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9670, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"other\"), env2->Global()) .FromJust()"
); } } while (0)
9670 .FromJust())do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("other"), env2->Global()) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 9670, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"other\"), env2->Global()) .FromJust()"
); } } while (0)
;
9671
9672 // Check that we have access to other.p in env2 from env1.
9673 Local<Value> result = CompileRun("other.p");
9674 CHECK(result->IsInt32())do { if ((__builtin_expect(!!(!(result->IsInt32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9674, "Check failed: %s."
, "result->IsInt32()"); } } while (0)
;
9675 CHECK_EQ(42, result->Int32Value(env1.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(env1.local()).FromJust()), "42" " " "=="
" " "result->Int32Value(env1.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 9675, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
9676
9677 // Hold on to global from env2 and detach global from env2.
9678 Local<v8::Object> global2 = env2->Global();
9679 env2->DetachGlobal();
9680
9681 // Check that the global has been detached. No other.p property can
9682 // be found.
9683 result = CompileRun("other.p");
9684 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9684, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
9685
9686 // Reuse global2 for env3.
9687 v8::Local<Context> env3 = Context::New(
9688 env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(), global2);
9689 CHECK(global2->Equals(env1.local(), env3->Global()).FromJust())do { if ((__builtin_expect(!!(!(global2->Equals(env1.local
(), env3->Global()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9689, "Check failed: %s.", "global2->Equals(env1.local(), env3->Global()).FromJust()"
); } } while (0)
;
9690
9691 // Start by using the same security token for env3 as for env1 and env2.
9692 env3->SetSecurityToken(foo);
9693
9694 // Create a property on the global object in env3.
9695 {
9696 v8::Context::Scope scope(env3);
9697 CHECK(env3->Global()do { if ((__builtin_expect(!!(!(env3->Global() ->Set(env3
, v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9699
, "Check failed: %s.", "env3->Global() ->Set(env3, v8_str(\"p\"), v8::Integer::New(env3->GetIsolate(), 24)) .FromJust()"
); } } while (0)
9698 ->Set(env3, v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24))do { if ((__builtin_expect(!!(!(env3->Global() ->Set(env3
, v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9699
, "Check failed: %s.", "env3->Global() ->Set(env3, v8_str(\"p\"), v8::Integer::New(env3->GetIsolate(), 24)) .FromJust()"
); } } while (0)
9699 .FromJust())do { if ((__builtin_expect(!!(!(env3->Global() ->Set(env3
, v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24)) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9699
, "Check failed: %s.", "env3->Global() ->Set(env3, v8_str(\"p\"), v8::Integer::New(env3->GetIsolate(), 24)) .FromJust()"
); } } while (0)
;
9700 }
9701
9702 // Check that other.p is now the property in env3 and that we have access.
9703 result = CompileRun("other.p");
9704 CHECK(result->IsInt32())do { if ((__builtin_expect(!!(!(result->IsInt32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9704, "Check failed: %s."
, "result->IsInt32()"); } } while (0)
;
9705 CHECK_EQ(24, result->Int32Value(env3).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (24), (
result->Int32Value(env3).FromJust()), "24" " " "==" " " "result->Int32Value(env3).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9705, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9706
9707 // Change security token for env3 to something different from env1 and env2.
9708 env3->SetSecurityToken(v8_str("bar"));
9709
9710 // Check that we do not have access to other.p in env1. |other| is now
9711 // the global object for env3 which has a different security token,
9712 // so access should be blocked.
9713 result = CompileRun("other.p");
9714 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9714, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
9715}
9716
9717
9718void GetThisX(const v8::FunctionCallbackInfo<v8::Value>& info) {
9719 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
9720 info.GetReturnValue().Set(
9721 context->Global()->Get(context, v8_str("x")).ToLocalChecked());
9722}
9723
9724
9725TEST(DetachedAccesses)static void TestDetachedAccesses(); CcTest register_test_DetachedAccesses
(TestDetachedAccesses, "../test/cctest/test-api.cc", "DetachedAccesses"
, __null, true, true); static void TestDetachedAccesses()
{
9726 LocalContext env1;
9727 v8::HandleScope scope(env1->GetIsolate());
9728
9729 // Create second environment.
9730 Local<ObjectTemplate> inner_global_template =
9731 FunctionTemplate::New(env1->GetIsolate())->InstanceTemplate();
9732 inner_global_template ->SetAccessorProperty(
9733 v8_str("this_x"), FunctionTemplate::New(env1->GetIsolate(), GetThisX));
9734 v8::Local<Context> env2 =
9735 Context::New(env1->GetIsolate(), NULL__null, inner_global_template);
9736
9737 Local<Value> foo = v8_str("foo");
9738
9739 // Set same security token for env1 and env2.
9740 env1->SetSecurityToken(foo);
9741 env2->SetSecurityToken(foo);
9742
9743 CHECK(env1->Global()do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("x"), v8_str("env1_x")) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9745, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"x\"), v8_str(\"env1_x\")) .FromJust()"
); } } while (0)
9744 ->Set(env1.local(), v8_str("x"), v8_str("env1_x"))do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("x"), v8_str("env1_x")) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9745, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"x\"), v8_str(\"env1_x\")) .FromJust()"
); } } while (0)
9745 .FromJust())do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("x"), v8_str("env1_x")) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 9745, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"x\"), v8_str(\"env1_x\")) .FromJust()"
); } } while (0)
;
9746
9747 {
9748 v8::Context::Scope scope(env2);
9749 CHECK(env2->Global()->Set(env2, v8_str("x"), v8_str("env2_x")).FromJust())do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
, v8_str("x"), v8_str("env2_x")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9749, "Check failed: %s.", "env2->Global()->Set(env2, v8_str(\"x\"), v8_str(\"env2_x\")).FromJust()"
); } } while (0)
;
9750 CompileRun(
9751 "function bound_x() { return x; }"
9752 "function get_x() { return this.x; }"
9753 "function get_x_w() { return (function() {return this.x;})(); }");
9754 CHECK(env1->Global()do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("bound_x"), CompileRun("bound_x")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9756, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"bound_x\"), CompileRun(\"bound_x\")) .FromJust()"
); } } while (0)
9755 ->Set(env1.local(), v8_str("bound_x"), CompileRun("bound_x"))do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("bound_x"), CompileRun("bound_x")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9756, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"bound_x\"), CompileRun(\"bound_x\")) .FromJust()"
); } } while (0)
9756 .FromJust())do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("bound_x"), CompileRun("bound_x")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9756, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"bound_x\"), CompileRun(\"bound_x\")) .FromJust()"
); } } while (0)
;
9757 CHECK(env1->Global()do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("get_x"), CompileRun("get_x")) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 9759, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"get_x\"), CompileRun(\"get_x\")) .FromJust()"
); } } while (0)
9758 ->Set(env1.local(), v8_str("get_x"), CompileRun("get_x"))do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("get_x"), CompileRun("get_x")) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 9759, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"get_x\"), CompileRun(\"get_x\")) .FromJust()"
); } } while (0)
9759 .FromJust())do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("get_x"), CompileRun("get_x")) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 9759, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"get_x\"), CompileRun(\"get_x\")) .FromJust()"
); } } while (0)
;
9760 CHECK(env1->Global()do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("get_x_w"), CompileRun("get_x_w")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9762, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"get_x_w\"), CompileRun(\"get_x_w\")) .FromJust()"
); } } while (0)
9761 ->Set(env1.local(), v8_str("get_x_w"), CompileRun("get_x_w"))do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("get_x_w"), CompileRun("get_x_w")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9762, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"get_x_w\"), CompileRun(\"get_x_w\")) .FromJust()"
); } } while (0)
9762 .FromJust())do { if ((__builtin_expect(!!(!(env1->Global() ->Set(env1
.local(), v8_str("get_x_w"), CompileRun("get_x_w")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9762, "Check failed: %s."
, "env1->Global() ->Set(env1.local(), v8_str(\"get_x_w\"), CompileRun(\"get_x_w\")) .FromJust()"
); } } while (0)
;
9763 env1->Global()
9764 ->Set(env1.local(), v8_str("this_x"),
9765 CompileRun("Object.getOwnPropertyDescriptor(this, 'this_x').get"))
9766 .FromJust();
9767 }
9768
9769 Local<Object> env2_global = env2->Global();
9770 env2->DetachGlobal();
9771
9772 Local<Value> result;
9773 result = CompileRun("bound_x()");
9774 CHECK(v8_str("env2_x")->Equals(env1.local(), result).FromJust())do { if ((__builtin_expect(!!(!(v8_str("env2_x")->Equals(env1
.local(), result).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9774, "Check failed: %s.", "v8_str(\"env2_x\")->Equals(env1.local(), result).FromJust()"
); } } while (0)
;
9775 result = CompileRun("get_x()");
9776 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9776, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
9777 result = CompileRun("get_x_w()");
9778 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9778, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
9779 result = CompileRun("this_x()");
9780 CHECK(v8_str("env2_x")->Equals(env1.local(), result).FromJust())do { if ((__builtin_expect(!!(!(v8_str("env2_x")->Equals(env1
.local(), result).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9780, "Check failed: %s.", "v8_str(\"env2_x\")->Equals(env1.local(), result).FromJust()"
); } } while (0)
;
9781
9782 // Reattach env2's proxy
9783 env2 = Context::New(env1->GetIsolate(), 0, v8::Local<v8::ObjectTemplate>(),
9784 env2_global);
9785 env2->SetSecurityToken(foo);
9786 {
9787 v8::Context::Scope scope(env2);
9788 CHECK(env2->Global()->Set(env2, v8_str("x"), v8_str("env3_x")).FromJust())do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
, v8_str("x"), v8_str("env3_x")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9788, "Check failed: %s.", "env2->Global()->Set(env2, v8_str(\"x\"), v8_str(\"env3_x\")).FromJust()"
); } } while (0)
;
9789 CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust())do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
, v8_str("env1"), env1->Global()).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 9789, "Check failed: %s.", "env2->Global()->Set(env2, v8_str(\"env1\"), env1->Global()).FromJust()"
); } } while (0)
;
9790 result = CompileRun(
9791 "results = [];"
9792 "for (var i = 0; i < 4; i++ ) {"
9793 " results.push(env1.bound_x());"
9794 " results.push(env1.get_x());"
9795 " results.push(env1.get_x_w());"
9796 " results.push(env1.this_x());"
9797 "}"
9798 "results");
9799 Local<v8::Array> results = Local<v8::Array>::Cast(result);
9800 CHECK_EQ(16u, results->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16u), (
results->Length()), "16u" " " "==" " " "results->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9800, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9801 for (int i = 0; i < 16; i += 4) {
9802 CHECK(v8_str("env2_x")do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env2, results->Get(env2, i + 0).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9804, "Check failed: %s."
, "v8_str(\"env2_x\") ->Equals(env2, results->Get(env2, i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
9803 ->Equals(env2, results->Get(env2, i + 0).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env2, results->Get(env2, i + 0).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9804, "Check failed: %s."
, "v8_str(\"env2_x\") ->Equals(env2, results->Get(env2, i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
9804 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env2, results->Get(env2, i + 0).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9804, "Check failed: %s."
, "v8_str(\"env2_x\") ->Equals(env2, results->Get(env2, i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9805 CHECK(v8_str("env1_x")do { if ((__builtin_expect(!!(!(v8_str("env1_x") ->Equals(
env2, results->Get(env2, i + 1).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9807, "Check failed: %s."
, "v8_str(\"env1_x\") ->Equals(env2, results->Get(env2, i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
9806 ->Equals(env2, results->Get(env2, i + 1).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env1_x") ->Equals(
env2, results->Get(env2, i + 1).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9807, "Check failed: %s."
, "v8_str(\"env1_x\") ->Equals(env2, results->Get(env2, i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
9807 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env1_x") ->Equals(
env2, results->Get(env2, i + 1).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9807, "Check failed: %s."
, "v8_str(\"env1_x\") ->Equals(env2, results->Get(env2, i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9808 CHECK(v8_str("env3_x")do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env2, results->Get(env2, i + 2).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9810, "Check failed: %s."
, "v8_str(\"env3_x\") ->Equals(env2, results->Get(env2, i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
9809 ->Equals(env2, results->Get(env2, i + 2).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env2, results->Get(env2, i + 2).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9810, "Check failed: %s."
, "v8_str(\"env3_x\") ->Equals(env2, results->Get(env2, i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
9810 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env2, results->Get(env2, i + 2).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9810, "Check failed: %s."
, "v8_str(\"env3_x\") ->Equals(env2, results->Get(env2, i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9811 CHECK(v8_str("env2_x")do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env2, results->Get(env2, i + 3).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9813, "Check failed: %s."
, "v8_str(\"env2_x\") ->Equals(env2, results->Get(env2, i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
9812 ->Equals(env2, results->Get(env2, i + 3).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env2, results->Get(env2, i + 3).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9813, "Check failed: %s."
, "v8_str(\"env2_x\") ->Equals(env2, results->Get(env2, i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
9813 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env2, results->Get(env2, i + 3).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9813, "Check failed: %s."
, "v8_str(\"env2_x\") ->Equals(env2, results->Get(env2, i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9814 }
9815 }
9816
9817 result = CompileRun(
9818 "results = [];"
9819 "for (var i = 0; i < 4; i++ ) {"
9820 " results.push(bound_x());"
9821 " results.push(get_x());"
9822 " results.push(get_x_w());"
9823 " results.push(this_x());"
9824 "}"
9825 "results");
9826 Local<v8::Array> results = Local<v8::Array>::Cast(result);
9827 CHECK_EQ(16u, results->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16u), (
results->Length()), "16u" " " "==" " " "results->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9828 for (int i = 0; i < 16; i += 4) {
9829 CHECK(v8_str("env2_x")do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9832, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
9830 ->Equals(env1.local(),do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9832, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
9831 results->Get(env1.local(), i + 0).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9832, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
9832 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9832, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9833 CHECK(v8_str("env3_x")do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9836, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
9834 ->Equals(env1.local(),do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9836, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
9835 results->Get(env1.local(), i + 1).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9836, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
9836 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9836, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9837 CHECK(v8_str("env3_x")do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9840, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
9838 ->Equals(env1.local(),do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9840, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
9839 results->Get(env1.local(), i + 2).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9840, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
9840 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9840, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9841 CHECK(v8_str("env2_x")do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9844, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
9842 ->Equals(env1.local(),do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9844, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
9843 results->Get(env1.local(), i + 3).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9844, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
9844 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9844, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9845 }
9846
9847 result = CompileRun(
9848 "results = [];"
9849 "for (var i = 0; i < 4; i++ ) {"
9850 " results.push(this.bound_x());"
9851 " results.push(this.get_x());"
9852 " results.push(this.get_x_w());"
9853 " results.push(this.this_x());"
9854 "}"
9855 "results");
9856 results = Local<v8::Array>::Cast(result);
9857 CHECK_EQ(16u, results->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16u), (
results->Length()), "16u" " " "==" " " "results->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 9857, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
9858 for (int i = 0; i < 16; i += 4) {
9859 CHECK(v8_str("env2_x")do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9862, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
9860 ->Equals(env1.local(),do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9862, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
9861 results->Get(env1.local(), i + 0).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9862, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
9862 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9862, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 0).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9863 CHECK(v8_str("env1_x")do { if ((__builtin_expect(!!(!(v8_str("env1_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9866, "Check failed: %s.", "v8_str(\"env1_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
9864 ->Equals(env1.local(),do { if ((__builtin_expect(!!(!(v8_str("env1_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9866, "Check failed: %s.", "v8_str(\"env1_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
9865 results->Get(env1.local(), i + 1).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env1_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9866, "Check failed: %s.", "v8_str(\"env1_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
9866 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env1_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9866, "Check failed: %s.", "v8_str(\"env1_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 1).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9867 CHECK(v8_str("env3_x")do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9870, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
9868 ->Equals(env1.local(),do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9870, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
9869 results->Get(env1.local(), i + 2).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9870, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
9870 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env3_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9870, "Check failed: %s.", "v8_str(\"env3_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 2).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9871 CHECK(v8_str("env2_x")do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9874, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
9872 ->Equals(env1.local(),do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9874, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
9873 results->Get(env1.local(), i + 3).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9874, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
9874 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("env2_x") ->Equals(
env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9874, "Check failed: %s.", "v8_str(\"env2_x\") ->Equals(env1.local(), results->Get(env1.local(), i + 3).ToLocalChecked()) .FromJust()"
); } } while (0)
;
9875 }
9876}
9877
9878
9879static bool allowed_access = false;
9880static bool AccessBlocker(Local<v8::Context> accessing_context,
9881 Local<v8::Object> accessed_object,
9882 Local<v8::Value> data) {
9883 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
9884 return context->Global()->Equals(context, accessed_object).FromJust() ||
9885 allowed_access;
9886}
9887
9888
9889static int g_echo_value = -1;
9890
9891
9892static void EchoGetter(
9893 Local<String> name,
9894 const v8::PropertyCallbackInfo<v8::Value>& info) {
9895 info.GetReturnValue().Set(v8_num(g_echo_value));
9896}
9897
9898
9899static void EchoSetter(Local<String> name, Local<Value> value,
9900 const v8::PropertyCallbackInfo<void>& args) {
9901 if (value->IsNumber())
9902 g_echo_value =
9903 value->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust();
9904}
9905
9906
9907static void UnreachableGetter(
9908 Local<String> name,
9909 const v8::PropertyCallbackInfo<v8::Value>& info) {
9910 CHECK(false)do { if ((__builtin_expect(!!(!(false)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9910, "Check failed: %s.", "false"); } } while (0)
; // This function should not be called..
9911}
9912
9913
9914static void UnreachableSetter(Local<String>,
9915 Local<Value>,
9916 const v8::PropertyCallbackInfo<void>&) {
9917 CHECK(false)do { if ((__builtin_expect(!!(!(false)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9917, "Check failed: %s.", "false"); } } while (0)
; // This function should nto be called.
9918}
9919
9920
9921static void UnreachableFunction(
9922 const v8::FunctionCallbackInfo<v8::Value>& info) {
9923 CHECK(false)do { if ((__builtin_expect(!!(!(false)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9923, "Check failed: %s.", "false"); } } while (0)
; // This function should not be called..
9924}
9925
9926
9927TEST(AccessControl)static void TestAccessControl(); CcTest register_test_AccessControl
(TestAccessControl, "../test/cctest/test-api.cc", "AccessControl"
, __null, true, true); static void TestAccessControl()
{
9928 v8::Isolate* isolate = CcTest::isolate();
9929 v8::HandleScope handle_scope(isolate);
9930 v8::Local<v8::ObjectTemplate> global_template =
9931 v8::ObjectTemplate::New(isolate);
9932
9933 global_template->SetAccessCheckCallback(AccessBlocker);
9934
9935 // Add an accessor accessible by cross-domain JS code.
9936 global_template->SetAccessor(
9937 v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Local<Value>(),
9938 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
9939
9940
9941 // Add an accessor that is not accessible by cross-domain JS code.
9942 global_template->SetAccessor(v8_str("blocked_prop"), UnreachableGetter,
9943 UnreachableSetter, v8::Local<Value>(),
9944 v8::DEFAULT);
9945
9946 global_template->SetAccessorProperty(
9947 v8_str("blocked_js_prop"),
9948 v8::FunctionTemplate::New(isolate, UnreachableFunction),
9949 v8::FunctionTemplate::New(isolate, UnreachableFunction),
9950 v8::None,
9951 v8::DEFAULT);
9952
9953 // Create an environment
9954 v8::Local<Context> context0 = Context::New(isolate, NULL__null, global_template);
9955 context0->Enter();
9956
9957 v8::Local<v8::Object> global0 = context0->Global();
9958
9959 // Define a property with JS getter and setter.
9960 CompileRun(
9961 "function getter() { return 'getter'; };\n"
9962 "function setter() { return 'setter'; }\n"
9963 "Object.defineProperty(this, 'js_accessor_p', {get:getter, set:setter})");
9964
9965 Local<Value> getter =
9966 global0->Get(context0, v8_str("getter")).ToLocalChecked();
9967 Local<Value> setter =
9968 global0->Get(context0, v8_str("setter")).ToLocalChecked();
9969
9970 // And define normal element.
9971 CHECK(global0->Set(context0, 239, v8_str("239")).FromJust())do { if ((__builtin_expect(!!(!(global0->Set(context0, 239
, v8_str("239")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9971, "Check failed: %s.", "global0->Set(context0, 239, v8_str(\"239\")).FromJust()"
); } } while (0)
;
9972
9973 // Define an element with JS getter and setter.
9974 CompileRun(
9975 "function el_getter() { return 'el_getter'; };\n"
9976 "function el_setter() { return 'el_setter'; };\n"
9977 "Object.defineProperty(this, '42', {get: el_getter, set: el_setter});");
9978
9979 Local<Value> el_getter =
9980 global0->Get(context0, v8_str("el_getter")).ToLocalChecked();
9981 Local<Value> el_setter =
9982 global0->Get(context0, v8_str("el_setter")).ToLocalChecked();
9983
9984 v8::HandleScope scope1(isolate);
9985
9986 v8::Local<Context> context1 = Context::New(isolate);
9987 context1->Enter();
9988
9989 v8::Local<v8::Object> global1 = context1->Global();
9990 CHECK(global1->Set(context1, v8_str("other"), global0).FromJust())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("other"), global0).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 9990, "Check failed: %s.", "global1->Set(context1, v8_str(\"other\"), global0).FromJust()"
); } } while (0)
;
9991
9992 // Access blocked property.
9993 CompileRun("other.blocked_prop = 1");
9994
9995 CHECK(CompileRun("other.blocked_prop").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other.blocked_prop"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9995
, "Check failed: %s.", "CompileRun(\"other.blocked_prop\").IsEmpty()"
); } } while (0)
;
9996 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')")do { if ((__builtin_expect(!!(!(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
9997, "Check failed: %s.", "CompileRun(\"Object.getOwnPropertyDescriptor(other, 'blocked_prop')\") .IsEmpty()"
); } } while (0)
9997 .IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
9997, "Check failed: %s.", "CompileRun(\"Object.getOwnPropertyDescriptor(other, 'blocked_prop')\") .IsEmpty()"
); } } while (0)
;
9998 CHECK(do { if ((__builtin_expect(!!(!(CompileRun("propertyIsEnumerable.call(other, 'blocked_prop')"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9999
, "Check failed: %s.", "CompileRun(\"propertyIsEnumerable.call(other, 'blocked_prop')\").IsEmpty()"
); } } while (0)
9999 CompileRun("propertyIsEnumerable.call(other, 'blocked_prop')").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("propertyIsEnumerable.call(other, 'blocked_prop')"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 9999
, "Check failed: %s.", "CompileRun(\"propertyIsEnumerable.call(other, 'blocked_prop')\").IsEmpty()"
); } } while (0)
;
10000
10001 // Access blocked element.
10002 CHECK(CompileRun("other[239] = 1").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other[239] = 1").
IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10002
, "Check failed: %s.", "CompileRun(\"other[239] = 1\").IsEmpty()"
); } } while (0)
;
10003
10004 CHECK(CompileRun("other[239]").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other[239]").IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10004, "Check failed: %s."
, "CompileRun(\"other[239]\").IsEmpty()"); } } while (0)
;
10005 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, '239')").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("Object.getOwnPropertyDescriptor(other, '239')"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10005
, "Check failed: %s.", "CompileRun(\"Object.getOwnPropertyDescriptor(other, '239')\").IsEmpty()"
); } } while (0)
;
10006 CHECK(CompileRun("propertyIsEnumerable.call(other, '239')").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("propertyIsEnumerable.call(other, '239')"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10006
, "Check failed: %s.", "CompileRun(\"propertyIsEnumerable.call(other, '239')\").IsEmpty()"
); } } while (0)
;
10007
10008 allowed_access = true;
10009 // Now we can enumerate the property.
10010 ExpectTrue("propertyIsEnumerable.call(other, '239')");
10011 allowed_access = false;
10012
10013 // Access a property with JS accessor.
10014 CHECK(CompileRun("other.js_accessor_p = 2").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other.js_accessor_p = 2"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10014
, "Check failed: %s.", "CompileRun(\"other.js_accessor_p = 2\").IsEmpty()"
); } } while (0)
;
10015
10016 CHECK(CompileRun("other.js_accessor_p").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other.js_accessor_p"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10016
, "Check failed: %s.", "CompileRun(\"other.js_accessor_p\").IsEmpty()"
); } } while (0)
;
10017 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, 'js_accessor_p')")do { if ((__builtin_expect(!!(!(CompileRun("Object.getOwnPropertyDescriptor(other, 'js_accessor_p')"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10018, "Check failed: %s.", "CompileRun(\"Object.getOwnPropertyDescriptor(other, 'js_accessor_p')\") .IsEmpty()"
); } } while (0)
10018 .IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("Object.getOwnPropertyDescriptor(other, 'js_accessor_p')"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10018, "Check failed: %s.", "CompileRun(\"Object.getOwnPropertyDescriptor(other, 'js_accessor_p')\") .IsEmpty()"
); } } while (0)
;
10019
10020 allowed_access = true;
10021
10022 ExpectString("other.js_accessor_p", "getter");
10023 ExpectObject(
10024 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').get", getter);
10025 ExpectObject(
10026 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').set", setter);
10027 ExpectUndefined(
10028 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').value");
10029
10030 allowed_access = false;
10031
10032 // Access an element with JS accessor.
10033 CHECK(CompileRun("other[42] = 2").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other[42] = 2").IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10033, "Check failed: %s."
, "CompileRun(\"other[42] = 2\").IsEmpty()"); } } while (0)
;
10034
10035 CHECK(CompileRun("other[42]").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other[42]").IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10035, "Check failed: %s."
, "CompileRun(\"other[42]\").IsEmpty()"); } } while (0)
;
10036 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, '42')").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("Object.getOwnPropertyDescriptor(other, '42')"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10036
, "Check failed: %s.", "CompileRun(\"Object.getOwnPropertyDescriptor(other, '42')\").IsEmpty()"
); } } while (0)
;
10037
10038 allowed_access = true;
10039
10040 ExpectString("other[42]", "el_getter");
10041 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').get", el_getter);
10042 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').set", el_setter);
10043 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').value");
10044
10045 allowed_access = false;
10046
10047 v8::Local<Value> value;
10048
10049 // Access accessible property
10050 value = CompileRun("other.accessible_prop = 3");
10051 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10051, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10052 CHECK_EQ(3, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (value
->Int32Value(context1).FromJust()), "3" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10052, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10053 CHECK_EQ(3, g_echo_value)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (g_echo_value
), "3" " " "==" " " "g_echo_value")) { V8_Fatal("../test/cctest/test-api.cc"
, 10053, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
10054
10055 value = CompileRun("other.accessible_prop");
10056 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10056, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10057 CHECK_EQ(3, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (value
->Int32Value(context1).FromJust()), "3" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10057, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10058
10059 value = CompileRun(
10060 "Object.getOwnPropertyDescriptor(other, 'accessible_prop').value");
10061 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10061, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10062 CHECK_EQ(3, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (value
->Int32Value(context1).FromJust()), "3" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10063
10064 value = CompileRun("propertyIsEnumerable.call(other, 'accessible_prop')");
10065 CHECK(value->IsTrue())do { if ((__builtin_expect(!!(!(value->IsTrue())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10065, "Check failed: %s.", "value->IsTrue()"
); } } while (0)
;
10066
10067 // Enumeration doesn't enumerate accessors from inaccessible objects in
10068 // the prototype chain even if the accessors are in themselves accessible.
10069 // Enumeration doesn't throw, it silently ignores what it can't access.
10070 value = CompileRun(
10071 "(function() {"
10072 " var obj = { '__proto__': other };"
10073 " try {"
10074 " for (var p in obj) {"
10075 " if (p == 'accessible_prop' ||"
10076 " p == 'blocked_js_prop' ||"
10077 " p == 'blocked_js_prop') {"
10078 " return false;"
10079 " }"
10080 " }"
10081 " return true;"
10082 " } catch (e) {"
10083 " return false;"
10084 " }"
10085 "})()");
10086 CHECK(value->IsTrue())do { if ((__builtin_expect(!!(!(value->IsTrue())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10086, "Check failed: %s.", "value->IsTrue()"
); } } while (0)
;
10087
10088 // Test that preventExtensions fails on a non-accessible object even if that
10089 // object is already non-extensible.
10090 CHECK(global1->Set(context1, v8_str("checked_object"),do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("checked_object"), global_template->NewInstance(context1)
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10092, "Check failed: %s.", "global1->Set(context1, v8_str(\"checked_object\"), global_template->NewInstance(context1).ToLocalChecked()) .FromJust()"
); } } while (0)
10091 global_template->NewInstance(context1).ToLocalChecked())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("checked_object"), global_template->NewInstance(context1)
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10092, "Check failed: %s.", "global1->Set(context1, v8_str(\"checked_object\"), global_template->NewInstance(context1).ToLocalChecked()) .FromJust()"
); } } while (0)
10092 .FromJust())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("checked_object"), global_template->NewInstance(context1)
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10092, "Check failed: %s.", "global1->Set(context1, v8_str(\"checked_object\"), global_template->NewInstance(context1).ToLocalChecked()) .FromJust()"
); } } while (0)
;
10093 allowed_access = true;
10094 CompileRun("Object.preventExtensions(checked_object)");
10095 ExpectFalse("Object.isExtensible(checked_object)");
10096 allowed_access = false;
10097 CHECK(CompileRun("Object.preventExtensions(checked_object)").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("Object.preventExtensions(checked_object)"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10097
, "Check failed: %s.", "CompileRun(\"Object.preventExtensions(checked_object)\").IsEmpty()"
); } } while (0)
;
10098
10099 context1->Exit();
10100 context0->Exit();
10101}
10102
10103
10104TEST(AccessControlES5)static void TestAccessControlES5(); CcTest register_test_AccessControlES5
(TestAccessControlES5, "../test/cctest/test-api.cc", "AccessControlES5"
, __null, true, true); static void TestAccessControlES5()
{
10105 v8::Isolate* isolate = CcTest::isolate();
10106 v8::HandleScope handle_scope(isolate);
10107 v8::Local<v8::ObjectTemplate> global_template =
10108 v8::ObjectTemplate::New(isolate);
10109
10110 global_template->SetAccessCheckCallback(AccessBlocker);
10111
10112 // Add accessible accessor.
10113 global_template->SetAccessor(
10114 v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Local<Value>(),
10115 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
10116
10117
10118 // Add an accessor that is not accessible by cross-domain JS code.
10119 global_template->SetAccessor(v8_str("blocked_prop"), UnreachableGetter,
10120 UnreachableSetter, v8::Local<Value>(),
10121 v8::DEFAULT);
10122
10123 // Create an environment
10124 v8::Local<Context> context0 = Context::New(isolate, NULL__null, global_template);
10125 context0->Enter();
10126
10127 v8::Local<v8::Object> global0 = context0->Global();
10128
10129 v8::Local<Context> context1 = Context::New(isolate);
10130 context1->Enter();
10131 v8::Local<v8::Object> global1 = context1->Global();
10132 CHECK(global1->Set(context1, v8_str("other"), global0).FromJust())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("other"), global0).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10132, "Check failed: %s.", "global1->Set(context1, v8_str(\"other\"), global0).FromJust()"
); } } while (0)
;
10133
10134 // Regression test for issue 1154.
10135 CHECK(CompileRun("Object.keys(other).length == 1")do { if ((__builtin_expect(!!(!(CompileRun("Object.keys(other).length == 1"
) ->BooleanValue(context1) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10137, "Check failed: %s.", "CompileRun(\"Object.keys(other).length == 1\") ->BooleanValue(context1) .FromJust()"
); } } while (0)
10136 ->BooleanValue(context1)do { if ((__builtin_expect(!!(!(CompileRun("Object.keys(other).length == 1"
) ->BooleanValue(context1) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10137, "Check failed: %s.", "CompileRun(\"Object.keys(other).length == 1\") ->BooleanValue(context1) .FromJust()"
); } } while (0)
10137 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("Object.keys(other).length == 1"
) ->BooleanValue(context1) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10137, "Check failed: %s.", "CompileRun(\"Object.keys(other).length == 1\") ->BooleanValue(context1) .FromJust()"
); } } while (0)
;
10138 CHECK(CompileRun("Object.keys(other)[0] == 'accessible_prop'")do { if ((__builtin_expect(!!(!(CompileRun("Object.keys(other)[0] == 'accessible_prop'"
) ->BooleanValue(context1) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10140, "Check failed: %s.", "CompileRun(\"Object.keys(other)[0] == 'accessible_prop'\") ->BooleanValue(context1) .FromJust()"
); } } while (0)
10139 ->BooleanValue(context1)do { if ((__builtin_expect(!!(!(CompileRun("Object.keys(other)[0] == 'accessible_prop'"
) ->BooleanValue(context1) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10140, "Check failed: %s.", "CompileRun(\"Object.keys(other)[0] == 'accessible_prop'\") ->BooleanValue(context1) .FromJust()"
); } } while (0)
10140 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("Object.keys(other)[0] == 'accessible_prop'"
) ->BooleanValue(context1) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10140, "Check failed: %s.", "CompileRun(\"Object.keys(other)[0] == 'accessible_prop'\") ->BooleanValue(context1) .FromJust()"
); } } while (0)
;
10141 CHECK(CompileRun("other.blocked_prop").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other.blocked_prop"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10141
, "Check failed: %s.", "CompileRun(\"other.blocked_prop\").IsEmpty()"
); } } while (0)
;
10142
10143 // Regression test for issue 1027.
10144 CompileRun("Object.defineProperty(\n"
10145 " other, 'blocked_prop', {configurable: false})");
10146 CHECK(CompileRun("other.blocked_prop").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other.blocked_prop"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10146
, "Check failed: %s.", "CompileRun(\"other.blocked_prop\").IsEmpty()"
); } } while (0)
;
10147 CHECK(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')")do { if ((__builtin_expect(!!(!(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10148, "Check failed: %s.", "CompileRun(\"Object.getOwnPropertyDescriptor(other, 'blocked_prop')\") .IsEmpty()"
); } } while (0)
10148 .IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("Object.getOwnPropertyDescriptor(other, 'blocked_prop')"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10148, "Check failed: %s.", "CompileRun(\"Object.getOwnPropertyDescriptor(other, 'blocked_prop')\") .IsEmpty()"
); } } while (0)
;
10149
10150 // Regression test for issue 1171.
10151 ExpectTrue("Object.isExtensible(other)");
10152 CompileRun("Object.preventExtensions(other)");
10153 ExpectTrue("Object.isExtensible(other)");
10154
10155 // Object.seal and Object.freeze.
10156 CompileRun("Object.freeze(other)");
10157 ExpectTrue("Object.isExtensible(other)");
10158
10159 CompileRun("Object.seal(other)");
10160 ExpectTrue("Object.isExtensible(other)");
10161
10162 // Regression test for issue 1250.
10163 // Make sure that we can set the accessible accessors value using normal
10164 // assignment.
10165 CompileRun("other.accessible_prop = 42");
10166 CHECK_EQ(42, g_echo_value)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
g_echo_value), "42" " " "==" " " "g_echo_value")) { V8_Fatal(
"../test/cctest/test-api.cc", 10166, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10167
10168 // [[DefineOwnProperty]] always throws for access-checked objects.
10169 CHECK(do { if ((__builtin_expect(!!(!(CompileRun("Object.defineProperty(other, 'accessible_prop', {value: 43})"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10171, "Check failed: %s.", "CompileRun(\"Object.defineProperty(other, 'accessible_prop', {value: 43})\") .IsEmpty()"
); } } while (0)
10170 CompileRun("Object.defineProperty(other, 'accessible_prop', {value: 43})")do { if ((__builtin_expect(!!(!(CompileRun("Object.defineProperty(other, 'accessible_prop', {value: 43})"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10171, "Check failed: %s.", "CompileRun(\"Object.defineProperty(other, 'accessible_prop', {value: 43})\") .IsEmpty()"
); } } while (0)
10171 .IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("Object.defineProperty(other, 'accessible_prop', {value: 43})"
) .IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10171, "Check failed: %s.", "CompileRun(\"Object.defineProperty(other, 'accessible_prop', {value: 43})\") .IsEmpty()"
); } } while (0)
;
10172 CHECK(CompileRun("other.accessible_prop == 42")->IsTrue())do { if ((__builtin_expect(!!(!(CompileRun("other.accessible_prop == 42"
)->IsTrue())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10172, "Check failed: %s.", "CompileRun(\"other.accessible_prop == 42\")->IsTrue()"
); } } while (0)
;
10173 CHECK_EQ(42, g_echo_value)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
g_echo_value), "42" " " "==" " " "g_echo_value")) { V8_Fatal(
"../test/cctest/test-api.cc", 10173, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
; // Make sure we didn't call the setter.
10174}
10175
10176static bool AccessAlwaysBlocked(Local<v8::Context> accessing_context,
10177 Local<v8::Object> global,
10178 Local<v8::Value> data) {
10179 i::PrintF("Access blocked.\n");
10180 return false;
10181}
10182
10183
10184THREADED_TEST(AccessControlGetOwnPropertyNames)static void TestAccessControlGetOwnPropertyNames(); RegisterThreadedTest
register_AccessControlGetOwnPropertyNames(TestAccessControlGetOwnPropertyNames
, "AccessControlGetOwnPropertyNames"); static void TestAccessControlGetOwnPropertyNames
(); CcTest register_test_AccessControlGetOwnPropertyNames(TestAccessControlGetOwnPropertyNames
, "../test/cctest/test-api.cc", "AccessControlGetOwnPropertyNames"
, __null, true, true); static void TestAccessControlGetOwnPropertyNames
()
{
10185 v8::Isolate* isolate = CcTest::isolate();
10186 v8::HandleScope handle_scope(isolate);
10187 v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
10188
10189 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42));
10190 obj_template->SetAccessCheckCallback(AccessAlwaysBlocked);
10191
10192 // Add an accessor accessible by cross-domain JS code.
10193 obj_template->SetAccessor(
10194 v8_str("accessible_prop"), EchoGetter, EchoSetter, v8::Local<Value>(),
10195 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
10196
10197 // Create an environment
10198 v8::Local<Context> context0 = Context::New(isolate, NULL__null, obj_template);
10199 context0->Enter();
10200
10201 v8::Local<v8::Object> global0 = context0->Global();
10202
10203 v8::HandleScope scope1(CcTest::isolate());
10204
10205 v8::Local<Context> context1 = Context::New(isolate);
10206 context1->Enter();
10207
10208 v8::Local<v8::Object> global1 = context1->Global();
10209 CHECK(global1->Set(context1, v8_str("other"), global0).FromJust())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("other"), global0).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10209, "Check failed: %s.", "global1->Set(context1, v8_str(\"other\"), global0).FromJust()"
); } } while (0)
;
10210 CHECK(global1->Set(context1, v8_str("object"),do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("object"), obj_template->NewInstance(context1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10212, "Check failed: %s.", "global1->Set(context1, v8_str(\"object\"), obj_template->NewInstance(context1).ToLocalChecked()) .FromJust()"
); } } while (0)
10211 obj_template->NewInstance(context1).ToLocalChecked())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("object"), obj_template->NewInstance(context1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10212, "Check failed: %s.", "global1->Set(context1, v8_str(\"object\"), obj_template->NewInstance(context1).ToLocalChecked()) .FromJust()"
); } } while (0)
10212 .FromJust())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("object"), obj_template->NewInstance(context1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10212, "Check failed: %s.", "global1->Set(context1, v8_str(\"object\"), obj_template->NewInstance(context1).ToLocalChecked()) .FromJust()"
); } } while (0)
;
10213
10214 v8::Local<Value> value;
10215
10216 // Attempt to get the property names of the other global object and
10217 // of an object that requires access checks. Accessing the other
10218 // global object should be blocked by access checks on the global
10219 // proxy object. Accessing the object that requires access checks
10220 // is blocked by the access checks on the object itself.
10221 value = CompileRun(
10222 "var names = Object.getOwnPropertyNames(other);"
10223 "names.length == 1 && names[0] == 'accessible_prop';");
10224 CHECK(value->BooleanValue(context1).FromJust())do { if ((__builtin_expect(!!(!(value->BooleanValue(context1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10224, "Check failed: %s.", "value->BooleanValue(context1).FromJust()"
); } } while (0)
;
10225
10226 value = CompileRun(
10227 "var names = Object.getOwnPropertyNames(object);"
10228 "names.length == 1 && names[0] == 'accessible_prop';");
10229 CHECK(value->BooleanValue(context1).FromJust())do { if ((__builtin_expect(!!(!(value->BooleanValue(context1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10229, "Check failed: %s.", "value->BooleanValue(context1).FromJust()"
); } } while (0)
;
10230
10231 context1->Exit();
10232 context0->Exit();
10233}
10234
10235
10236TEST(Regress470113)static void TestRegress470113(); CcTest register_test_Regress470113
(TestRegress470113, "../test/cctest/test-api.cc", "Regress470113"
, __null, true, true); static void TestRegress470113()
{
10237 v8::Isolate* isolate = CcTest::isolate();
10238 v8::HandleScope handle_scope(isolate);
10239 v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
10240 obj_template->SetAccessCheckCallback(AccessAlwaysBlocked);
10241 LocalContext env;
10242 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("prohibited"), obj_template->NewInstance(
env.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10245, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"prohibited\"), obj_template->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
10243 ->Set(env.local(), v8_str("prohibited"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("prohibited"), obj_template->NewInstance(
env.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10245, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"prohibited\"), obj_template->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
10244 obj_template->NewInstance(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("prohibited"), obj_template->NewInstance(
env.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10245, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"prohibited\"), obj_template->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
10245 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("prohibited"), obj_template->NewInstance(
env.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10245, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"prohibited\"), obj_template->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
10246
10247 {
10248 v8::TryCatch try_catch(isolate);
10249 CompileRun(
10250 "'use strict';\n"
10251 "class C extends Object {\n"
10252 " m() { super.powned = 'Powned!'; }\n"
10253 "}\n"
10254 "let c = new C();\n"
10255 "c.m.call(prohibited)");
10256
10257 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10257, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
10258 }
10259}
10260
10261
10262static void ConstTenGetter(Local<String> name,
10263 const v8::PropertyCallbackInfo<v8::Value>& info) {
10264 info.GetReturnValue().Set(v8_num(10));
10265}
10266
10267
10268THREADED_TEST(CrossDomainAccessors)static void TestCrossDomainAccessors(); RegisterThreadedTest register_CrossDomainAccessors
(TestCrossDomainAccessors, "CrossDomainAccessors"); static void
TestCrossDomainAccessors(); CcTest register_test_CrossDomainAccessors
(TestCrossDomainAccessors, "../test/cctest/test-api.cc", "CrossDomainAccessors"
, __null, true, true); static void TestCrossDomainAccessors()
{
10269 v8::Isolate* isolate = CcTest::isolate();
10270 v8::HandleScope handle_scope(isolate);
10271
10272 v8::Local<v8::FunctionTemplate> func_template =
10273 v8::FunctionTemplate::New(isolate);
10274
10275 v8::Local<v8::ObjectTemplate> global_template =
10276 func_template->InstanceTemplate();
10277
10278 v8::Local<v8::ObjectTemplate> proto_template =
10279 func_template->PrototypeTemplate();
10280
10281 // Add an accessor to proto that's accessible by cross-domain JS code.
10282 proto_template->SetAccessor(v8_str("accessible"), ConstTenGetter, 0,
10283 v8::Local<Value>(), v8::ALL_CAN_READ);
10284
10285 // Add an accessor that is not accessible by cross-domain JS code.
10286 global_template->SetAccessor(v8_str("unreachable"), UnreachableGetter, 0,
10287 v8::Local<Value>(), v8::DEFAULT);
10288
10289 v8::Local<Context> context0 = Context::New(isolate, NULL__null, global_template);
10290 context0->Enter();
10291
10292 Local<v8::Object> global = context0->Global();
10293 // Add a normal property that shadows 'accessible'
10294 CHECK(global->Set(context0, v8_str("accessible"), v8_num(11)).FromJust())do { if ((__builtin_expect(!!(!(global->Set(context0, v8_str
("accessible"), v8_num(11)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10294, "Check failed: %s.", "global->Set(context0, v8_str(\"accessible\"), v8_num(11)).FromJust()"
); } } while (0)
;
10295
10296 // Enter a new context.
10297 v8::HandleScope scope1(CcTest::isolate());
10298 v8::Local<Context> context1 = Context::New(isolate);
10299 context1->Enter();
10300
10301 v8::Local<v8::Object> global1 = context1->Global();
10302 CHECK(global1->Set(context1, v8_str("other"), global).FromJust())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("other"), global).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10302, "Check failed: %s.", "global1->Set(context1, v8_str(\"other\"), global).FromJust()"
); } } while (0)
;
10303
10304 // Should return 10, instead of 11
10305 v8::Local<Value> value =
10306 v8_compile("other.accessible")->Run(context1).ToLocalChecked();
10307 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10307, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10308 CHECK_EQ(10, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10), (
value->Int32Value(context1).FromJust()), "10" " " "==" " "
"value->Int32Value(context1).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 10308, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
10309
10310 v8::MaybeLocal<v8::Value> maybe_value =
10311 v8_compile("other.unreachable")->Run(context1);
10312 CHECK(maybe_value.IsEmpty())do { if ((__builtin_expect(!!(!(maybe_value.IsEmpty())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10312, "Check failed: %s."
, "maybe_value.IsEmpty()"); } } while (0)
;
10313
10314 context1->Exit();
10315 context0->Exit();
10316}
10317
10318
10319static int access_count = 0;
10320
10321static bool AccessCounter(Local<v8::Context> accessing_context,
10322 Local<v8::Object> accessed_object,
10323 Local<v8::Value> data) {
10324 access_count++;
10325 return true;
10326}
10327
10328
10329// This one is too easily disturbed by other tests.
10330TEST(AccessControlIC)static void TestAccessControlIC(); CcTest register_test_AccessControlIC
(TestAccessControlIC, "../test/cctest/test-api.cc", "AccessControlIC"
, __null, true, true); static void TestAccessControlIC()
{
10331 access_count = 0;
10332
10333 v8::Isolate* isolate = CcTest::isolate();
10334 v8::HandleScope handle_scope(isolate);
10335
10336 // Create an environment.
10337 v8::Local<Context> context0 = Context::New(isolate);
10338 context0->Enter();
10339
10340 // Create an object that requires access-check functions to be
10341 // called for cross-domain access.
10342 v8::Local<v8::ObjectTemplate> object_template =
10343 v8::ObjectTemplate::New(isolate);
10344 object_template->SetAccessCheckCallback(AccessCounter);
10345 Local<v8::Object> object =
10346 object_template->NewInstance(context0).ToLocalChecked();
10347
10348 v8::HandleScope scope1(isolate);
10349
10350 // Create another environment.
10351 v8::Local<Context> context1 = Context::New(isolate);
10352 context1->Enter();
10353
10354 // Make easy access to the object from the other environment.
10355 v8::Local<v8::Object> global1 = context1->Global();
10356 CHECK(global1->Set(context1, v8_str("obj"), object).FromJust())do { if ((__builtin_expect(!!(!(global1->Set(context1, v8_str
("obj"), object).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10356, "Check failed: %s.", "global1->Set(context1, v8_str(\"obj\"), object).FromJust()"
); } } while (0)
;
10357
10358 v8::Local<Value> value;
10359
10360 // Check that the named access-control function is called every time.
10361 CompileRun("function testProp(obj) {"
10362 " for (var i = 0; i < 10; i++) obj.prop = 1;"
10363 " for (var j = 0; j < 10; j++) obj.prop;"
10364 " return obj.prop"
10365 "}");
10366 value = CompileRun("testProp(obj)");
10367 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10367, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10368 CHECK_EQ(1, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(context1).FromJust()), "1" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10368, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10369 CHECK_EQ(21, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (21), (
access_count), "21" " " "==" " " "access_count")) { V8_Fatal(
"../test/cctest/test-api.cc", 10369, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10370
10371 // Check that the named access-control function is called every time.
10372 CompileRun("var p = 'prop';"
10373 "function testKeyed(obj) {"
10374 " for (var i = 0; i < 10; i++) obj[p] = 1;"
10375 " for (var j = 0; j < 10; j++) obj[p];"
10376 " return obj[p];"
10377 "}");
10378 // Use obj which requires access checks. No inline caching is used
10379 // in that case.
10380 value = CompileRun("testKeyed(obj)");
10381 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10381, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10382 CHECK_EQ(1, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(context1).FromJust()), "1" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10382, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10383 CHECK_EQ(42, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
access_count), "42" " " "==" " " "access_count")) { V8_Fatal(
"../test/cctest/test-api.cc", 10383, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10384 // Force the inline caches into generic state and try again.
10385 CompileRun("testKeyed({ a: 0 })");
10386 CompileRun("testKeyed({ b: 0 })");
10387 value = CompileRun("testKeyed(obj)");
10388 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10388, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10389 CHECK_EQ(1, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(context1).FromJust()), "1" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10389, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10390 CHECK_EQ(63, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (63), (
access_count), "63" " " "==" " " "access_count")) { V8_Fatal(
"../test/cctest/test-api.cc", 10390, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10391
10392 // Check that the indexed access-control function is called every time.
10393 access_count = 0;
10394
10395 CompileRun("function testIndexed(obj) {"
10396 " for (var i = 0; i < 10; i++) obj[0] = 1;"
10397 " for (var j = 0; j < 10; j++) obj[0];"
10398 " return obj[0]"
10399 "}");
10400 value = CompileRun("testIndexed(obj)");
10401 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10401, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10402 CHECK_EQ(1, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(context1).FromJust()), "1" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10402, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10403 CHECK_EQ(21, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (21), (
access_count), "21" " " "==" " " "access_count")) { V8_Fatal(
"../test/cctest/test-api.cc", 10403, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10404 // Force the inline caches into generic state.
10405 CompileRun("testIndexed(new Array(1))");
10406 // Test that the indexed access check is called.
10407 value = CompileRun("testIndexed(obj)");
10408 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10408, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10409 CHECK_EQ(1, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(context1).FromJust()), "1" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10409, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10410 CHECK_EQ(42, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
access_count), "42" " " "==" " " "access_count")) { V8_Fatal(
"../test/cctest/test-api.cc", 10410, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10411
10412 access_count = 0;
10413 // Check that the named access check is called when invoking
10414 // functions on an object that requires access checks.
10415 CompileRun("obj.f = function() {}");
10416 CompileRun("function testCallNormal(obj) {"
10417 " for (var i = 0; i < 10; i++) obj.f();"
10418 "}");
10419 CompileRun("testCallNormal(obj)");
10420 printf("%i\n", access_count);
10421 CHECK_EQ(11, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (11), (
access_count), "11" " " "==" " " "access_count")) { V8_Fatal(
"../test/cctest/test-api.cc", 10421, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10422
10423 // Force obj into slow case.
10424 value = CompileRun("delete obj.prop");
10425 CHECK(value->BooleanValue(context1).FromJust())do { if ((__builtin_expect(!!(!(value->BooleanValue(context1
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
10425, "Check failed: %s.", "value->BooleanValue(context1).FromJust()"
); } } while (0)
;
10426 // Force inline caches into dictionary probing mode.
10427 CompileRun("var o = { x: 0 }; delete o.x; testProp(o);");
10428 // Test that the named access check is called.
10429 value = CompileRun("testProp(obj);");
10430 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10430, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
10431 CHECK_EQ(1, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(context1).FromJust()), "1" " " "==" " " "value->Int32Value(context1).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10431, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10432 CHECK_EQ(33, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (33), (
access_count), "33" " " "==" " " "access_count")) { V8_Fatal(
"../test/cctest/test-api.cc", 10432, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10433
10434 // Force the call inline cache into dictionary probing mode.
10435 CompileRun("o.f = function() {}; testCallNormal(o)");
10436 // Test that the named access check is still called for each
10437 // invocation of the function.
10438 value = CompileRun("testCallNormal(obj)");
10439 CHECK_EQ(43, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (43), (
access_count), "43" " " "==" " " "access_count")) { V8_Fatal(
"../test/cctest/test-api.cc", 10439, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10440
10441 context1->Exit();
10442 context0->Exit();
10443}
10444
10445
10446THREADED_TEST(Version)static void TestVersion(); RegisterThreadedTest register_Version
(TestVersion, "Version"); static void TestVersion(); CcTest register_test_Version
(TestVersion, "../test/cctest/test-api.cc", "Version", __null
, true, true); static void TestVersion()
{ v8::V8::GetVersion(); }
10447
10448
10449static void InstanceFunctionCallback(
10450 const v8::FunctionCallbackInfo<v8::Value>& args) {
10451 ApiTestFuzzer::Fuzz();
10452 args.GetReturnValue().Set(v8_num(12));
10453}
10454
10455
10456THREADED_TEST(InstanceProperties)static void TestInstanceProperties(); RegisterThreadedTest register_InstanceProperties
(TestInstanceProperties, "InstanceProperties"); static void TestInstanceProperties
(); CcTest register_test_InstanceProperties(TestInstanceProperties
, "../test/cctest/test-api.cc", "InstanceProperties", __null,
true, true); static void TestInstanceProperties()
{
10457 LocalContext context;
10458 v8::Isolate* isolate = context->GetIsolate();
10459 v8::HandleScope handle_scope(isolate);
10460
10461 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
10462 Local<ObjectTemplate> instance = t->InstanceTemplate();
10463
10464 instance->Set(v8_str("x"), v8_num(42));
10465 instance->Set(v8_str("f"),
10466 v8::FunctionTemplate::New(isolate, InstanceFunctionCallback));
10467
10468 Local<Value> o = t->GetFunction(context.local())
10469 .ToLocalChecked()
10470 ->NewInstance(context.local())
10471 .ToLocalChecked();
10472
10473 CHECK(context->Global()->Set(context.local(), v8_str("i"), o).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("i"), o).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10473, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"i\"), o).FromJust()"
); } } while (0)
;
10474 Local<Value> value = CompileRun("i.x");
10475 CHECK_EQ(42, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 10475, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10476
10477 value = CompileRun("i.f()");
10478 CHECK_EQ(12, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
value->Int32Value(context.local()).FromJust()), "12" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 10478, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10479}
10480
10481
10482static void GlobalObjectInstancePropertiesGet(
10483 Local<Name> key, const v8::PropertyCallbackInfo<v8::Value>&) {
10484 ApiTestFuzzer::Fuzz();
10485}
10486
10487
10488THREADED_TEST(GlobalObjectInstanceProperties)static void TestGlobalObjectInstanceProperties(); RegisterThreadedTest
register_GlobalObjectInstanceProperties(TestGlobalObjectInstanceProperties
, "GlobalObjectInstanceProperties"); static void TestGlobalObjectInstanceProperties
(); CcTest register_test_GlobalObjectInstanceProperties(TestGlobalObjectInstanceProperties
, "../test/cctest/test-api.cc", "GlobalObjectInstanceProperties"
, __null, true, true); static void TestGlobalObjectInstanceProperties
()
{
10489 v8::Isolate* isolate = CcTest::isolate();
10490 v8::HandleScope handle_scope(isolate);
10491
10492 Local<Value> global_object;
10493
10494 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
10495 t->InstanceTemplate()->SetHandler(
10496 v8::NamedPropertyHandlerConfiguration(GlobalObjectInstancePropertiesGet));
10497 Local<ObjectTemplate> instance_template = t->InstanceTemplate();
10498 instance_template->Set(v8_str("x"), v8_num(42));
10499 instance_template->Set(v8_str("f"),
10500 v8::FunctionTemplate::New(isolate,
10501 InstanceFunctionCallback));
10502
10503 // The script to check how Crankshaft compiles missing global function
10504 // invocations. function g is not defined and should throw on call.
10505 const char* script =
10506 "function wrapper(call) {"
10507 " var x = 0, y = 1;"
10508 " for (var i = 0; i < 1000; i++) {"
10509 " x += i * 100;"
10510 " y += i * 100;"
10511 " }"
10512 " if (call) g();"
10513 "}"
10514 "for (var i = 0; i < 17; i++) wrapper(false);"
10515 "var thrown = 0;"
10516 "try { wrapper(true); } catch (e) { thrown = 1; };"
10517 "thrown";
10518
10519 {
10520 LocalContext env(NULL__null, instance_template);
10521 // Hold on to the global object so it can be used again in another
10522 // environment initialization.
10523 global_object = env->Global();
10524
10525 Local<Value> value = CompileRun("x");
10526 CHECK_EQ(42, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(env.local()).FromJust()), "42" " " "==" " "
"value->Int32Value(env.local()).FromJust()")) { V8_Fatal(
"../test/cctest/test-api.cc", 10526, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10527 value = CompileRun("f()");
10528 CHECK_EQ(12, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
value->Int32Value(env.local()).FromJust()), "12" " " "==" " "
"value->Int32Value(env.local()).FromJust()")) { V8_Fatal(
"../test/cctest/test-api.cc", 10528, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10529 value = CompileRun(script);
10530 CHECK_EQ(1, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(env.local()).FromJust()), "1" " " "==" " " "value->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10530, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10531 }
10532
10533 {
10534 // Create new environment reusing the global object.
10535 LocalContext env(NULL__null, instance_template, global_object);
10536 Local<Value> value = CompileRun("x");
10537 CHECK_EQ(42, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(env.local()).FromJust()), "42" " " "==" " "
"value->Int32Value(env.local()).FromJust()")) { V8_Fatal(
"../test/cctest/test-api.cc", 10537, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10538 value = CompileRun("f()");
10539 CHECK_EQ(12, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
value->Int32Value(env.local()).FromJust()), "12" " " "==" " "
"value->Int32Value(env.local()).FromJust()")) { V8_Fatal(
"../test/cctest/test-api.cc", 10539, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10540 value = CompileRun(script);
10541 CHECK_EQ(1, value->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(env.local()).FromJust()), "1" " " "==" " " "value->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10541, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10542 }
10543}
10544
10545
10546THREADED_TEST(CallKnownGlobalReceiver)static void TestCallKnownGlobalReceiver(); RegisterThreadedTest
register_CallKnownGlobalReceiver(TestCallKnownGlobalReceiver
, "CallKnownGlobalReceiver"); static void TestCallKnownGlobalReceiver
(); CcTest register_test_CallKnownGlobalReceiver(TestCallKnownGlobalReceiver
, "../test/cctest/test-api.cc", "CallKnownGlobalReceiver", __null
, true, true); static void TestCallKnownGlobalReceiver()
{
10547 v8::Isolate* isolate = CcTest::isolate();
10548 v8::HandleScope handle_scope(isolate);
10549
10550 Local<Value> global_object;
10551
10552 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
10553 Local<ObjectTemplate> instance_template = t->InstanceTemplate();
10554
10555 // The script to check that we leave global object not
10556 // global object proxy on stack when we deoptimize from inside
10557 // arguments evaluation.
10558 // To provoke error we need to both force deoptimization
10559 // from arguments evaluation and to force CallIC to take
10560 // CallIC_Miss code path that can't cope with global proxy.
10561 const char* script =
10562 "function bar(x, y) { try { } finally { } }"
10563 "function baz(x) { try { } finally { } }"
10564 "function bom(x) { try { } finally { } }"
10565 "function foo(x) { bar([x], bom(2)); }"
10566 "for (var i = 0; i < 10000; i++) foo(1);"
10567 "foo";
10568
10569 Local<Value> foo;
10570 {
10571 LocalContext env(NULL__null, instance_template);
10572 // Hold on to the global object so it can be used again in another
10573 // environment initialization.
10574 global_object = env->Global();
10575 foo = CompileRun(script);
10576 }
10577
10578 {
10579 // Create new environment reusing the global object.
10580 LocalContext env(NULL__null, instance_template, global_object);
10581 CHECK(env->Global()->Set(env.local(), v8_str("foo"), foo).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("foo"), foo).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10581, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"foo\"), foo).FromJust()"
); } } while (0)
;
10582 CompileRun("foo()");
10583 }
10584}
10585
10586
10587static void ShadowFunctionCallback(
10588 const v8::FunctionCallbackInfo<v8::Value>& args) {
10589 ApiTestFuzzer::Fuzz();
10590 args.GetReturnValue().Set(v8_num(42));
10591}
10592
10593
10594static int shadow_y;
10595static int shadow_y_setter_call_count;
10596static int shadow_y_getter_call_count;
10597
10598
10599static void ShadowYSetter(Local<String>,
10600 Local<Value>,
10601 const v8::PropertyCallbackInfo<void>&) {
10602 shadow_y_setter_call_count++;
10603 shadow_y = 42;
10604}
10605
10606
10607static void ShadowYGetter(Local<String> name,
10608 const v8::PropertyCallbackInfo<v8::Value>& info) {
10609 ApiTestFuzzer::Fuzz();
10610 shadow_y_getter_call_count++;
10611 info.GetReturnValue().Set(v8_num(shadow_y));
10612}
10613
10614
10615static void ShadowIndexedGet(uint32_t index,
10616 const v8::PropertyCallbackInfo<v8::Value>&) {
10617}
10618
10619
10620static void ShadowNamedGet(Local<Name> key,
10621 const v8::PropertyCallbackInfo<v8::Value>&) {}
10622
10623
10624THREADED_TEST(ShadowObject)static void TestShadowObject(); RegisterThreadedTest register_ShadowObject
(TestShadowObject, "ShadowObject"); static void TestShadowObject
(); CcTest register_test_ShadowObject(TestShadowObject, "../test/cctest/test-api.cc"
, "ShadowObject", __null, true, true); static void TestShadowObject
()
{
10625 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0;
10626 v8::Isolate* isolate = CcTest::isolate();
10627 v8::HandleScope handle_scope(isolate);
10628
10629 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate);
10630 LocalContext context(NULL__null, global_template);
10631
10632 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
10633 t->InstanceTemplate()->SetHandler(
10634 v8::NamedPropertyHandlerConfiguration(ShadowNamedGet));
10635 t->InstanceTemplate()->SetHandler(
10636 v8::IndexedPropertyHandlerConfiguration(ShadowIndexedGet));
10637 Local<ObjectTemplate> proto = t->PrototypeTemplate();
10638 Local<ObjectTemplate> instance = t->InstanceTemplate();
10639
10640 proto->Set(v8_str("f"),
10641 v8::FunctionTemplate::New(isolate,
10642 ShadowFunctionCallback,
10643 Local<Value>()));
10644 proto->Set(v8_str("x"), v8_num(12));
10645
10646 instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter);
10647
10648 Local<Value> o = t->GetFunction(context.local())
10649 .ToLocalChecked()
10650 ->NewInstance(context.local())
10651 .ToLocalChecked();
10652 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("__proto__"), o) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10654, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"__proto__\"), o) .FromJust()"
); } } while (0)
10653 ->Set(context.local(), v8_str("__proto__"), o)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("__proto__"), o) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10654, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"__proto__\"), o) .FromJust()"
); } } while (0)
10654 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("__proto__"), o) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10654, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"__proto__\"), o) .FromJust()"
); } } while (0)
;
10655
10656 Local<Value> value =
10657 CompileRun("this.propertyIsEnumerable(0)");
10658 CHECK(value->IsBoolean())do { if ((__builtin_expect(!!(!(value->IsBoolean())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10658, "Check failed: %s."
, "value->IsBoolean()"); } } while (0)
;
10659 CHECK(!value->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(!value->BooleanValue(context
.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10659, "Check failed: %s.", "!value->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
10660
10661 value = CompileRun("x");
10662 CHECK_EQ(12, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
value->Int32Value(context.local()).FromJust()), "12" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 10662, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10663
10664 value = CompileRun("f()");
10665 CHECK_EQ(42, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 10665, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10666
10667 CompileRun("y = 43");
10668 CHECK_EQ(1, shadow_y_setter_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (shadow_y_setter_call_count
), "1" " " "==" " " "shadow_y_setter_call_count")) { V8_Fatal
("../test/cctest/test-api.cc", 10668, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10669 value = CompileRun("y");
10670 CHECK_EQ(1, shadow_y_getter_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (shadow_y_getter_call_count
), "1" " " "==" " " "shadow_y_getter_call_count")) { V8_Fatal
("../test/cctest/test-api.cc", 10670, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10671 CHECK_EQ(42, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 10671, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
10672}
10673
10674
10675THREADED_TEST(HiddenPrototype)static void TestHiddenPrototype(); RegisterThreadedTest register_HiddenPrototype
(TestHiddenPrototype, "HiddenPrototype"); static void TestHiddenPrototype
(); CcTest register_test_HiddenPrototype(TestHiddenPrototype,
"../test/cctest/test-api.cc", "HiddenPrototype", __null, true
, true); static void TestHiddenPrototype()
{
10676 LocalContext context;
10677 v8::Isolate* isolate = context->GetIsolate();
10678 v8::HandleScope handle_scope(isolate);
10679
10680 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
10681 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
10682 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
10683 t1->SetHiddenPrototype(true);
10684 t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1));
10685 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
10686 t2->SetHiddenPrototype(true);
10687 t2->InstanceTemplate()->Set(v8_str("z"), v8_num(2));
10688 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
10689 t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3));
10690
10691 Local<v8::Object> o0 = t0->GetFunction(context.local())
10692 .ToLocalChecked()
10693 ->NewInstance(context.local())
10694 .ToLocalChecked();
10695 Local<v8::Object> o1 = t1->GetFunction(context.local())
10696 .ToLocalChecked()
10697 ->NewInstance(context.local())
10698 .ToLocalChecked();
10699 Local<v8::Object> o2 = t2->GetFunction(context.local())
10700 .ToLocalChecked()
10701 ->NewInstance(context.local())
10702 .ToLocalChecked();
10703 Local<v8::Object> o3 = t3->GetFunction(context.local())
10704 .ToLocalChecked()
10705 ->NewInstance(context.local())
10706 .ToLocalChecked();
10707
10708 // Setting the prototype on an object skips hidden prototypes.
10709 CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10712, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10710 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10712, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10711 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10712, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10712 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10712, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10713 CHECK(o0->Set(context.local(), v8_str("__proto__"), o1).FromJust())do { if ((__builtin_expect(!!(!(o0->Set(context.local(), v8_str
("__proto__"), o1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10713, "Check failed: %s.", "o0->Set(context.local(), v8_str(\"__proto__\"), o1).FromJust()"
); } } while (0)
;
10714 CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10717, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10715 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10717, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10716 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10717, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10717 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10717, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10718 CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10721, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10719 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10721, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10720 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10721, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10721 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10721, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10722 CHECK(o0->Set(context.local(), v8_str("__proto__"), o2).FromJust())do { if ((__builtin_expect(!!(!(o0->Set(context.local(), v8_str
("__proto__"), o2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10722, "Check failed: %s.", "o0->Set(context.local(), v8_str(\"__proto__\"), o2).FromJust()"
); } } while (0)
;
10723 CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10726, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10724 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10726, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10725 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10726, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10726 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10726, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10727 CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10730, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10728 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10730, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10729 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10730, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10730 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10730, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10731 CHECK_EQ(2, o0->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10734, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10732 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10734, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10733 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10734, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10734 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10734, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10735 CHECK(o0->Set(context.local(), v8_str("__proto__"), o3).FromJust())do { if ((__builtin_expect(!!(!(o0->Set(context.local(), v8_str
("__proto__"), o3).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10735, "Check failed: %s.", "o0->Set(context.local(), v8_str(\"__proto__\"), o3).FromJust()"
); } } while (0)
;
10736 CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10739, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10737 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10739, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10738 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10739, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10739 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10739, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10740 CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10743, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10741 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10743, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10742 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10743, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10743 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10743, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10744 CHECK_EQ(2, o0->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10747, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10745 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10747, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10746 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10747, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10747 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10747, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10748 CHECK_EQ(3, o0->Get(context.local(), v8_str("u"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (o0
->Get(context.local(), v8_str("u")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "o0->Get(context.local(), v8_str(\"u\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10751, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10749 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (o0
->Get(context.local(), v8_str("u")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "o0->Get(context.local(), v8_str(\"u\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10751, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10750 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (o0
->Get(context.local(), v8_str("u")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "o0->Get(context.local(), v8_str(\"u\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10751, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10751 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (o0
->Get(context.local(), v8_str("u")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "o0->Get(context.local(), v8_str(\"u\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10751, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10752
10753 // Getting the prototype of o0 should get the first visible one
10754 // which is o3. Therefore, z should not be defined on the prototype
10755 // object.
10756 Local<Value> proto =
10757 o0->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
10758 CHECK(proto->IsObject())do { if ((__builtin_expect(!!(!(proto->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10758, "Check failed: %s."
, "proto->IsObject()"); } } while (0)
;
10759 CHECK(proto.As<v8::Object>()do { if ((__builtin_expect(!!(!(proto.As<v8::Object>() ->
Get(context.local(), v8_str("z")) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10762, "Check failed: %s."
, "proto.As<v8::Object>() ->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
10760 ->Get(context.local(), v8_str("z"))do { if ((__builtin_expect(!!(!(proto.As<v8::Object>() ->
Get(context.local(), v8_str("z")) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10762, "Check failed: %s."
, "proto.As<v8::Object>() ->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
10761 .ToLocalChecked()do { if ((__builtin_expect(!!(!(proto.As<v8::Object>() ->
Get(context.local(), v8_str("z")) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10762, "Check failed: %s."
, "proto.As<v8::Object>() ->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
10762 ->IsUndefined())do { if ((__builtin_expect(!!(!(proto.As<v8::Object>() ->
Get(context.local(), v8_str("z")) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 10762, "Check failed: %s."
, "proto.As<v8::Object>() ->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
10763}
10764
10765
10766THREADED_TEST(HiddenPrototypeSet)static void TestHiddenPrototypeSet(); RegisterThreadedTest register_HiddenPrototypeSet
(TestHiddenPrototypeSet, "HiddenPrototypeSet"); static void TestHiddenPrototypeSet
(); CcTest register_test_HiddenPrototypeSet(TestHiddenPrototypeSet
, "../test/cctest/test-api.cc", "HiddenPrototypeSet", __null,
true, true); static void TestHiddenPrototypeSet()
{
10767 LocalContext context;
10768 v8::Isolate* isolate = context->GetIsolate();
10769 v8::HandleScope handle_scope(isolate);
10770
10771 Local<v8::FunctionTemplate> ot = v8::FunctionTemplate::New(isolate);
10772 Local<v8::FunctionTemplate> ht = v8::FunctionTemplate::New(isolate);
10773 ht->SetHiddenPrototype(true);
10774 Local<v8::FunctionTemplate> pt = v8::FunctionTemplate::New(isolate);
10775 ht->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
10776
10777 Local<v8::Object> o = ot->GetFunction(context.local())
10778 .ToLocalChecked()
10779 ->NewInstance(context.local())
10780 .ToLocalChecked();
10781 Local<v8::Object> h = ht->GetFunction(context.local())
10782 .ToLocalChecked()
10783 ->NewInstance(context.local())
10784 .ToLocalChecked();
10785 Local<v8::Object> p = pt->GetFunction(context.local())
10786 .ToLocalChecked()
10787 ->NewInstance(context.local())
10788 .ToLocalChecked();
10789 CHECK(o->Set(context.local(), v8_str("__proto__"), h).FromJust())do { if ((__builtin_expect(!!(!(o->Set(context.local(), v8_str
("__proto__"), h).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10789, "Check failed: %s.", "o->Set(context.local(), v8_str(\"__proto__\"), h).FromJust()"
); } } while (0)
;
10790 CHECK(h->Set(context.local(), v8_str("__proto__"), p).FromJust())do { if ((__builtin_expect(!!(!(h->Set(context.local(), v8_str
("__proto__"), p).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10790, "Check failed: %s.", "h->Set(context.local(), v8_str(\"__proto__\"), p).FromJust()"
); } } while (0)
;
10791
10792 // Setting a property that exists on the hidden prototype goes there.
10793 CHECK(o->Set(context.local(), v8_str("x"), v8_num(7)).FromJust())do { if ((__builtin_expect(!!(!(o->Set(context.local(), v8_str
("x"), v8_num(7)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10793, "Check failed: %s.", "o->Set(context.local(), v8_str(\"x\"), v8_num(7)).FromJust()"
); } } while (0)
;
10794 CHECK_EQ(7, o->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (o
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "7" " " "==" " " "o->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10797, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10795 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (o
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "7" " " "==" " " "o->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10797, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10796 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (o
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "7" " " "==" " " "o->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10797, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10797 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (o
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "7" " " "==" " " "o->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10797, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10798 CHECK_EQ(7, h->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (h
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "7" " " "==" " " "h->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10801, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10799 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (h
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "7" " " "==" " " "h->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10801, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10800 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (h
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "7" " " "==" " " "h->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10801, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10801 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (h
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "7" " " "==" " " "h->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10801, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10802 CHECK(p->Get(context.local(), v8_str("x")).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(p->Get(context.local(), v8_str
("x")).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10802, "Check failed: %s.", "p->Get(context.local(), v8_str(\"x\")).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
10803
10804 // Setting a new property should not be forwarded to the hidden prototype.
10805 CHECK(o->Set(context.local(), v8_str("y"), v8_num(6)).FromJust())do { if ((__builtin_expect(!!(!(o->Set(context.local(), v8_str
("y"), v8_num(6)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10805, "Check failed: %s.", "o->Set(context.local(), v8_str(\"y\"), v8_num(6)).FromJust()"
); } } while (0)
;
10806 CHECK_EQ(6, o->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (o
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "6" " " "==" " " "o->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10809, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10807 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (o
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "6" " " "==" " " "o->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10809, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10808 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (o
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "6" " " "==" " " "o->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10809, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10809 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (o
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "6" " " "==" " " "o->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10809, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10810 CHECK(h->Get(context.local(), v8_str("y")).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(h->Get(context.local(), v8_str
("y")).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10810, "Check failed: %s.", "h->Get(context.local(), v8_str(\"y\")).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
10811 CHECK(p->Get(context.local(), v8_str("y")).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(p->Get(context.local(), v8_str
("y")).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 10811, "Check failed: %s.", "p->Get(context.local(), v8_str(\"y\")).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
10812
10813 // Setting a property that only exists on a prototype of the hidden prototype
10814 // is treated normally again.
10815 CHECK(p->Set(context.local(), v8_str("z"), v8_num(8)).FromJust())do { if ((__builtin_expect(!!(!(p->Set(context.local(), v8_str
("z"), v8_num(8)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10815, "Check failed: %s.", "p->Set(context.local(), v8_str(\"z\"), v8_num(8)).FromJust()"
); } } while (0)
;
10816 CHECK_EQ(8, o->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (o
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "o->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10819, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10817 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (o
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "o->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10819, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10818 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (o
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "o->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10819, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10819 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (o
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "o->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10819, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10820 CHECK_EQ(8, h->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (h
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "h->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10823, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10821 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (h
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "h->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10823, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10822 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (h
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "h->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10823, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10823 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (h
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "h->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10823, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10824 CHECK_EQ(8, p->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (p
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "p->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10825 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (p
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "p->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10826 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (p
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "p->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10827 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (p
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "p->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10827, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10828 CHECK(o->Set(context.local(), v8_str("z"), v8_num(9)).FromJust())do { if ((__builtin_expect(!!(!(o->Set(context.local(), v8_str
("z"), v8_num(9)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10828, "Check failed: %s.", "o->Set(context.local(), v8_str(\"z\"), v8_num(9)).FromJust()"
); } } while (0)
;
10829 CHECK_EQ(9, o->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9), (o
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "9" " " "==" " " "o->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10832, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10830 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9), (o
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "9" " " "==" " " "o->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10832, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10831 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9), (o
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "9" " " "==" " " "o->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10832, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10832 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9), (o
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "9" " " "==" " " "o->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10832, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10833 CHECK_EQ(8, h->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (h
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "h->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10836, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10834 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (h
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "h->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10836, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10835 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (h
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "h->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10836, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10836 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (h
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "h->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10836, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10837 CHECK_EQ(8, p->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (p
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "p->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10840, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10838 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (p
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "p->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10840, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10839 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (p
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "p->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10840, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10840 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (8), (p
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "8" " " "==" " " "p->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10840, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10841}
10842
10843
10844// Regression test for issue 2457.
10845THREADED_TEST(HiddenPrototypeIdentityHash)static void TestHiddenPrototypeIdentityHash(); RegisterThreadedTest
register_HiddenPrototypeIdentityHash(TestHiddenPrototypeIdentityHash
, "HiddenPrototypeIdentityHash"); static void TestHiddenPrototypeIdentityHash
(); CcTest register_test_HiddenPrototypeIdentityHash(TestHiddenPrototypeIdentityHash
, "../test/cctest/test-api.cc", "HiddenPrototypeIdentityHash"
, __null, true, true); static void TestHiddenPrototypeIdentityHash
()
{
10846 LocalContext context;
10847 v8::HandleScope handle_scope(context->GetIsolate());
10848
10849 Local<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate());
10850 t->SetHiddenPrototype(true);
10851 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75));
10852 Local<Object> p = t->GetFunction(context.local())
10853 .ToLocalChecked()
10854 ->NewInstance(context.local())
10855 .ToLocalChecked();
10856 Local<Object> o = Object::New(context->GetIsolate());
10857 CHECK(o->SetPrototype(context.local(), p).FromJust())do { if ((__builtin_expect(!!(!(o->SetPrototype(context.local
(), p).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10857, "Check failed: %s.", "o->SetPrototype(context.local(), p).FromJust()"
); } } while (0)
;
10858
10859 int hash = o->GetIdentityHash();
10860 USE(hash);
10861 CHECK(o->Set(context.local(), v8_str("foo"), v8_num(42)).FromJust())do { if ((__builtin_expect(!!(!(o->Set(context.local(), v8_str
("foo"), v8_num(42)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10861, "Check failed: %s.", "o->Set(context.local(), v8_str(\"foo\"), v8_num(42)).FromJust()"
); } } while (0)
;
10862 CHECK_EQ(hash, o->GetIdentityHash())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (hash),
(o->GetIdentityHash()), "hash" " " "==" " " "o->GetIdentityHash()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10862, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10863}
10864
10865
10866THREADED_TEST(SetPrototype)static void TestSetPrototype(); RegisterThreadedTest register_SetPrototype
(TestSetPrototype, "SetPrototype"); static void TestSetPrototype
(); CcTest register_test_SetPrototype(TestSetPrototype, "../test/cctest/test-api.cc"
, "SetPrototype", __null, true, true); static void TestSetPrototype
()
{
10867 LocalContext context;
10868 v8::Isolate* isolate = context->GetIsolate();
10869 v8::HandleScope handle_scope(isolate);
10870
10871 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
10872 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
10873 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
10874 t1->SetHiddenPrototype(true);
10875 t1->InstanceTemplate()->Set(v8_str("y"), v8_num(1));
10876 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
10877 t2->SetHiddenPrototype(true);
10878 t2->InstanceTemplate()->Set(v8_str("z"), v8_num(2));
10879 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
10880 t3->InstanceTemplate()->Set(v8_str("u"), v8_num(3));
10881
10882 Local<v8::Object> o0 = t0->GetFunction(context.local())
10883 .ToLocalChecked()
10884 ->NewInstance(context.local())
10885 .ToLocalChecked();
10886 Local<v8::Object> o1 = t1->GetFunction(context.local())
10887 .ToLocalChecked()
10888 ->NewInstance(context.local())
10889 .ToLocalChecked();
10890 Local<v8::Object> o2 = t2->GetFunction(context.local())
10891 .ToLocalChecked()
10892 ->NewInstance(context.local())
10893 .ToLocalChecked();
10894 Local<v8::Object> o3 = t3->GetFunction(context.local())
10895 .ToLocalChecked()
10896 ->NewInstance(context.local())
10897 .ToLocalChecked();
10898
10899 // Setting the prototype on an object does not skip hidden prototypes.
10900 CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10901 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10902 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10903 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10904 CHECK(o0->SetPrototype(context.local(), o1).FromJust())do { if ((__builtin_expect(!!(!(o0->SetPrototype(context.local
(), o1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10904, "Check failed: %s.", "o0->SetPrototype(context.local(), o1).FromJust()"
); } } while (0)
;
10905 CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10908, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10906 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10908, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10907 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10908, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10908 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10908, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10909 CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10912, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10910 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10912, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10911 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10912, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10912 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10912, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10913 CHECK(o1->SetPrototype(context.local(), o2).FromJust())do { if ((__builtin_expect(!!(!(o1->SetPrototype(context.local
(), o2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10913, "Check failed: %s.", "o1->SetPrototype(context.local(), o2).FromJust()"
); } } while (0)
;
10914 CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10917, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10915 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10917, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10916 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10917, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10917 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10917, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10918 CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10921, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10919 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10921, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10920 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10921, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10921 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10921, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10922 CHECK_EQ(2, o0->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10925, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10923 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10925, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10924 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10925, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10925 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10925, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10926 CHECK(o2->SetPrototype(context.local(), o3).FromJust())do { if ((__builtin_expect(!!(!(o2->SetPrototype(context.local
(), o3).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10926, "Check failed: %s.", "o2->SetPrototype(context.local(), o3).FromJust()"
); } } while (0)
;
10927 CHECK_EQ(0, o0->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10930, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10928 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10930, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10929 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10930, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10930 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (o0
->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "o0->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10930, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10931 CHECK_EQ(1, o0->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10934, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10932 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10934, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10933 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10934, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10934 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (o0
->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "o0->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10934, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10935 CHECK_EQ(2, o0->Get(context.local(), v8_str("z"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10938, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10936 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10938, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10937 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10938, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10938 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (o0
->Get(context.local(), v8_str("z")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "2" " " "==" " " "o0->Get(context.local(), v8_str(\"z\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10938, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10939 CHECK_EQ(3, o0->Get(context.local(), v8_str("u"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (o0
->Get(context.local(), v8_str("u")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "o0->Get(context.local(), v8_str(\"u\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10942, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10940 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (o0
->Get(context.local(), v8_str("u")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "o0->Get(context.local(), v8_str(\"u\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10942, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10941 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (o0
->Get(context.local(), v8_str("u")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "o0->Get(context.local(), v8_str(\"u\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10942, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
10942 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (o0
->Get(context.local(), v8_str("u")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "o0->Get(context.local(), v8_str(\"u\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 10942, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
10943
10944 // Getting the prototype of o0 should get the first visible one
10945 // which is o3. Therefore, z should not be defined on the prototype
10946 // object.
10947 Local<Value> proto =
10948 o0->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
10949 CHECK(proto->IsObject())do { if ((__builtin_expect(!!(!(proto->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 10949, "Check failed: %s."
, "proto->IsObject()"); } } while (0)
;
10950 CHECK(proto.As<v8::Object>()->Equals(context.local(), o3).FromJust())do { if ((__builtin_expect(!!(!(proto.As<v8::Object>()->
Equals(context.local(), o3).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 10950, "Check failed: %s.", "proto.As<v8::Object>()->Equals(context.local(), o3).FromJust()"
); } } while (0)
;
10951
10952 // However, Object::GetPrototype ignores hidden prototype.
10953 Local<Value> proto0 = o0->GetPrototype();
10954 CHECK(proto0->IsObject())do { if ((__builtin_expect(!!(!(proto0->IsObject())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10954, "Check failed: %s."
, "proto0->IsObject()"); } } while (0)
;
10955 CHECK(proto0.As<v8::Object>()->Equals(context.local(), o1).FromJust())do { if ((__builtin_expect(!!(!(proto0.As<v8::Object>()
->Equals(context.local(), o1).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10955, "Check failed: %s.", "proto0.As<v8::Object>()->Equals(context.local(), o1).FromJust()"
); } } while (0)
;
10956
10957 Local<Value> proto1 = o1->GetPrototype();
10958 CHECK(proto1->IsObject())do { if ((__builtin_expect(!!(!(proto1->IsObject())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10958, "Check failed: %s."
, "proto1->IsObject()"); } } while (0)
;
10959 CHECK(proto1.As<v8::Object>()->Equals(context.local(), o2).FromJust())do { if ((__builtin_expect(!!(!(proto1.As<v8::Object>()
->Equals(context.local(), o2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10959, "Check failed: %s.", "proto1.As<v8::Object>()->Equals(context.local(), o2).FromJust()"
); } } while (0)
;
10960
10961 Local<Value> proto2 = o2->GetPrototype();
10962 CHECK(proto2->IsObject())do { if ((__builtin_expect(!!(!(proto2->IsObject())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 10962, "Check failed: %s."
, "proto2->IsObject()"); } } while (0)
;
10963 CHECK(proto2.As<v8::Object>()->Equals(context.local(), o3).FromJust())do { if ((__builtin_expect(!!(!(proto2.As<v8::Object>()
->Equals(context.local(), o3).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 10963, "Check failed: %s.", "proto2.As<v8::Object>()->Equals(context.local(), o3).FromJust()"
); } } while (0)
;
10964}
10965
10966
10967// Getting property names of an object with a prototype chain that
10968// triggers dictionary elements in GetOwnPropertyNames() shouldn't
10969// crash the runtime.
10970THREADED_TEST(Regress91517)static void TestRegress91517(); RegisterThreadedTest register_Regress91517
(TestRegress91517, "Regress91517"); static void TestRegress91517
(); CcTest register_test_Regress91517(TestRegress91517, "../test/cctest/test-api.cc"
, "Regress91517", __null, true, true); static void TestRegress91517
()
{
10971 i::FLAG_allow_natives_syntax = true;
10972 LocalContext context;
10973 v8::Isolate* isolate = context->GetIsolate();
10974 v8::HandleScope handle_scope(isolate);
10975
10976 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
10977 t1->SetHiddenPrototype(true);
10978 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1));
10979 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
10980 t2->SetHiddenPrototype(true);
10981 t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2));
10982 t2->InstanceTemplate()->Set(v8_str("objects"),
10983 v8::ObjectTemplate::New(isolate));
10984 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2));
10985 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
10986 t3->SetHiddenPrototype(true);
10987 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3));
10988 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate);
10989 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4));
10990
10991 // Force dictionary-based properties.
10992 i::ScopedVector<char> name_buf(1024);
10993 for (int i = 1; i <= 1000; i++) {
10994 i::SNPrintF(name_buf, "sdf%d", i);
10995 t2->InstanceTemplate()->Set(v8_str(name_buf.start()), v8_num(2));
10996 }
10997
10998 Local<v8::Object> o1 = t1->GetFunction(context.local())
10999 .ToLocalChecked()
11000 ->NewInstance(context.local())
11001 .ToLocalChecked();
11002 Local<v8::Object> o2 = t2->GetFunction(context.local())
11003 .ToLocalChecked()
11004 ->NewInstance(context.local())
11005 .ToLocalChecked();
11006 Local<v8::Object> o3 = t3->GetFunction(context.local())
11007 .ToLocalChecked()
11008 ->NewInstance(context.local())
11009 .ToLocalChecked();
11010 Local<v8::Object> o4 = t4->GetFunction(context.local())
11011 .ToLocalChecked()
11012 ->NewInstance(context.local())
11013 .ToLocalChecked();
11014
11015 // Create prototype chain of hidden prototypes.
11016 CHECK(o4->SetPrototype(context.local(), o3).FromJust())do { if ((__builtin_expect(!!(!(o4->SetPrototype(context.local
(), o3).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11016, "Check failed: %s.", "o4->SetPrototype(context.local(), o3).FromJust()"
); } } while (0)
;
11017 CHECK(o3->SetPrototype(context.local(), o2).FromJust())do { if ((__builtin_expect(!!(!(o3->SetPrototype(context.local
(), o2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11017, "Check failed: %s.", "o3->SetPrototype(context.local(), o2).FromJust()"
); } } while (0)
;
11018 CHECK(o2->SetPrototype(context.local(), o1).FromJust())do { if ((__builtin_expect(!!(!(o2->SetPrototype(context.local
(), o1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11018, "Check failed: %s.", "o2->SetPrototype(context.local(), o1).FromJust()"
); } } while (0)
;
11019
11020 // Call the runtime version of GetOwnPropertyNames() on the natively
11021 // created object through JavaScript.
11022 CHECK(context->Global()->Set(context.local(), v8_str("obj"), o4).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("obj"), o4).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11022, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"obj\"), o4).FromJust()"
); } } while (0)
;
11023 // PROPERTY_FILTER_NONE = 0
11024 CompileRun("var names = %GetOwnPropertyKeys(obj, 0);");
11025
11026 ExpectInt32("names.length", 1006);
11027 ExpectTrue("names.indexOf(\"baz\") >= 0");
11028 ExpectTrue("names.indexOf(\"boo\") >= 0");
11029 ExpectTrue("names.indexOf(\"foo\") >= 0");
11030 ExpectTrue("names.indexOf(\"fuz1\") >= 0");
11031 ExpectTrue("names.indexOf(\"objects\") >= 0");
11032 ExpectTrue("names.indexOf(\"fuz2\") >= 0");
11033 ExpectFalse("names[1005] == undefined");
11034}
11035
11036
11037// Getting property names of an object with a hidden and inherited
11038// prototype should not duplicate the accessor properties inherited.
11039THREADED_TEST(Regress269562)static void TestRegress269562(); RegisterThreadedTest register_Regress269562
(TestRegress269562, "Regress269562"); static void TestRegress269562
(); CcTest register_test_Regress269562(TestRegress269562, "../test/cctest/test-api.cc"
, "Regress269562", __null, true, true); static void TestRegress269562
()
{
11040 i::FLAG_allow_natives_syntax = true;
11041 LocalContext context;
11042 v8::HandleScope handle_scope(context->GetIsolate());
11043
11044 Local<v8::FunctionTemplate> t1 =
11045 v8::FunctionTemplate::New(context->GetIsolate());
11046 t1->SetHiddenPrototype(true);
11047
11048 Local<v8::ObjectTemplate> i1 = t1->InstanceTemplate();
11049 i1->SetAccessor(v8_str("foo"),
11050 SimpleAccessorGetter, SimpleAccessorSetter);
11051 i1->SetAccessor(v8_str("bar"),
11052 SimpleAccessorGetter, SimpleAccessorSetter);
11053 i1->SetAccessor(v8_str("baz"),
11054 SimpleAccessorGetter, SimpleAccessorSetter);
11055 i1->Set(v8_str("n1"), v8_num(1));
11056 i1->Set(v8_str("n2"), v8_num(2));
11057
11058 Local<v8::Object> o1 = t1->GetFunction(context.local())
11059 .ToLocalChecked()
11060 ->NewInstance(context.local())
11061 .ToLocalChecked();
11062 Local<v8::FunctionTemplate> t2 =
11063 v8::FunctionTemplate::New(context->GetIsolate());
11064 t2->SetHiddenPrototype(true);
11065
11066 // Inherit from t1 and mark prototype as hidden.
11067 t2->Inherit(t1);
11068 t2->InstanceTemplate()->Set(v8_str("mine"), v8_num(4));
11069
11070 Local<v8::Object> o2 = t2->GetFunction(context.local())
11071 .ToLocalChecked()
11072 ->NewInstance(context.local())
11073 .ToLocalChecked();
11074 CHECK(o2->SetPrototype(context.local(), o1).FromJust())do { if ((__builtin_expect(!!(!(o2->SetPrototype(context.local
(), o1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11074, "Check failed: %s.", "o2->SetPrototype(context.local(), o1).FromJust()"
); } } while (0)
;
11075
11076 v8::Local<v8::Symbol> sym =
11077 v8::Symbol::New(context->GetIsolate(), v8_str("s1"));
11078 CHECK(o1->Set(context.local(), sym, v8_num(3)).FromJust())do { if ((__builtin_expect(!!(!(o1->Set(context.local(), sym
, v8_num(3)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11078, "Check failed: %s.", "o1->Set(context.local(), sym, v8_num(3)).FromJust()"
); } } while (0)
;
11079 o1->SetPrivate(context.local(),
11080 v8::Private::New(context->GetIsolate(), v8_str("h1")),
11081 v8::Integer::New(context->GetIsolate(), 2013))
11082 .FromJust();
11083
11084 // Call the runtime version of GetOwnPropertyNames() on
11085 // the natively created object through JavaScript.
11086 CHECK(context->Global()->Set(context.local(), v8_str("obj"), o2).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("obj"), o2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11086, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"obj\"), o2).FromJust()"
); } } while (0)
;
11087 CHECK(context->Global()->Set(context.local(), v8_str("sym"), sym).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("sym"), sym).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11087, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"sym\"), sym).FromJust()"
); } } while (0)
;
11088 // PROPERTY_FILTER_NONE = 0
11089 CompileRun("var names = %GetOwnPropertyKeys(obj, 0);");
11090
11091 ExpectInt32("names.length", 7);
11092 ExpectTrue("names.indexOf(\"foo\") >= 0");
11093 ExpectTrue("names.indexOf(\"bar\") >= 0");
11094 ExpectTrue("names.indexOf(\"baz\") >= 0");
11095 ExpectTrue("names.indexOf(\"n1\") >= 0");
11096 ExpectTrue("names.indexOf(\"n2\") >= 0");
11097 ExpectTrue("names.indexOf(sym) >= 0");
11098 ExpectTrue("names.indexOf(\"mine\") >= 0");
11099}
11100
11101
11102THREADED_TEST(FunctionReadOnlyPrototype)static void TestFunctionReadOnlyPrototype(); RegisterThreadedTest
register_FunctionReadOnlyPrototype(TestFunctionReadOnlyPrototype
, "FunctionReadOnlyPrototype"); static void TestFunctionReadOnlyPrototype
(); CcTest register_test_FunctionReadOnlyPrototype(TestFunctionReadOnlyPrototype
, "../test/cctest/test-api.cc", "FunctionReadOnlyPrototype", __null
, true, true); static void TestFunctionReadOnlyPrototype()
{
11103 LocalContext context;
11104 v8::Isolate* isolate = context->GetIsolate();
11105 v8::HandleScope handle_scope(isolate);
11106
11107 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
11108 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(isolate, 42));
11109 t1->ReadOnlyPrototype();
11110 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func1"), t1->GetFunction(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11113, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"func1\"), t1->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
11111 ->Set(context.local(), v8_str("func1"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func1"), t1->GetFunction(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11113, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"func1\"), t1->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
11112 t1->GetFunction(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func1"), t1->GetFunction(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11113, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"func1\"), t1->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
11113 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func1"), t1->GetFunction(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11113, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"func1\"), t1->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
11114 // Configured value of ReadOnly flag.
11115 CHECK(do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
" return (descriptor['writable'] == false);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11122, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');\" \" return (descriptor['writable'] == false);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11116 CompileRun(do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
" return (descriptor['writable'] == false);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11122, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');\" \" return (descriptor['writable'] == false);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11117 "(function() {"do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
" return (descriptor['writable'] == false);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11122, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');\" \" return (descriptor['writable'] == false);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11118 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
" return (descriptor['writable'] == false);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11122, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');\" \" return (descriptor['writable'] == false);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11119 " return (descriptor['writable'] == false);"do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
" return (descriptor['writable'] == false);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11122, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');\" \" return (descriptor['writable'] == false);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11120 "})()")do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
" return (descriptor['writable'] == false);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11122, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');\" \" return (descriptor['writable'] == false);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11121 ->BooleanValue(context.local())do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
" return (descriptor['writable'] == false);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11122, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');\" \" return (descriptor['writable'] == false);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11122 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
" return (descriptor['writable'] == false);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11122, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');\" \" return (descriptor['writable'] == false);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
;
11123 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func1.prototype.x")->Int32Value(context.local(
)).FromJust()), "42" " " "==" " " "CompileRun(\"func1.prototype.x\")->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11125, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11124 42,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func1.prototype.x")->Int32Value(context.local(
)).FromJust()), "42" " " "==" " " "CompileRun(\"func1.prototype.x\")->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11125, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11125 CompileRun("func1.prototype.x")->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func1.prototype.x")->Int32Value(context.local(
)).FromJust()), "42" " " "==" " " "CompileRun(\"func1.prototype.x\")->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11125, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11126 CHECK_EQ(42, CompileRun("func1.prototype = {}; func1.prototype.x")do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func1.prototype = {}; func1.prototype.x") ->Int32Value
(context.local()) .FromJust()), "42" " " "==" " " "CompileRun(\"func1.prototype = {}; func1.prototype.x\") ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11128, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11127 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func1.prototype = {}; func1.prototype.x") ->Int32Value
(context.local()) .FromJust()), "42" " " "==" " " "CompileRun(\"func1.prototype = {}; func1.prototype.x\") ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11128, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11128 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func1.prototype = {}; func1.prototype.x") ->Int32Value
(context.local()) .FromJust()), "42" " " "==" " " "CompileRun(\"func1.prototype = {}; func1.prototype.x\") ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11128, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11129
11130 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
11131 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(isolate, 42));
11132 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func2"), t2->GetFunction(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11135, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"func2\"), t2->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
11133 ->Set(context.local(), v8_str("func2"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func2"), t2->GetFunction(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11135, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"func2\"), t2->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
11134 t2->GetFunction(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func2"), t2->GetFunction(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11135, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"func2\"), t2->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
11135 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func2"), t2->GetFunction(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11135, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"func2\"), t2->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
11136 // Default value of ReadOnly flag.
11137 CHECK(do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
" return (descriptor['writable'] == true);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11144, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');\" \" return (descriptor['writable'] == true);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11138 CompileRun(do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
" return (descriptor['writable'] == true);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11144, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');\" \" return (descriptor['writable'] == true);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11139 "(function() {"do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
" return (descriptor['writable'] == true);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11144, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');\" \" return (descriptor['writable'] == true);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11140 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
" return (descriptor['writable'] == true);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11144, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');\" \" return (descriptor['writable'] == true);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11141 " return (descriptor['writable'] == true);"do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
" return (descriptor['writable'] == true);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11144, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');\" \" return (descriptor['writable'] == true);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11142 "})()")do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
" return (descriptor['writable'] == true);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11144, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');\" \" return (descriptor['writable'] == true);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11143 ->BooleanValue(context.local())do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
" return (descriptor['writable'] == true);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11144, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');\" \" return (descriptor['writable'] == true);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11144 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun( "(function() {" " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
" return (descriptor['writable'] == true);" "})()") ->BooleanValue
(context.local()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11144, "Check failed: %s.", "CompileRun( \"(function() {\" \" descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');\" \" return (descriptor['writable'] == true);\" \"})()\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
;
11145 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func2.prototype.x")->Int32Value(context.local(
)).FromJust()), "42" " " "==" " " "CompileRun(\"func2.prototype.x\")->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11147, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11146 42,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func2.prototype.x")->Int32Value(context.local(
)).FromJust()), "42" " " "==" " " "CompileRun(\"func2.prototype.x\")->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11147, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11147 CompileRun("func2.prototype.x")->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("func2.prototype.x")->Int32Value(context.local(
)).FromJust()), "42" " " "==" " " "CompileRun(\"func2.prototype.x\")->Int32Value(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11147, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11148}
11149
11150
11151THREADED_TEST(SetPrototypeThrows)static void TestSetPrototypeThrows(); RegisterThreadedTest register_SetPrototypeThrows
(TestSetPrototypeThrows, "SetPrototypeThrows"); static void TestSetPrototypeThrows
(); CcTest register_test_SetPrototypeThrows(TestSetPrototypeThrows
, "../test/cctest/test-api.cc", "SetPrototypeThrows", __null,
true, true); static void TestSetPrototypeThrows()
{
11152 LocalContext context;
11153 v8::Isolate* isolate = context->GetIsolate();
11154 v8::HandleScope handle_scope(isolate);
11155
11156 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
11157
11158 Local<v8::Object> o0 = t->GetFunction(context.local())
11159 .ToLocalChecked()
11160 ->NewInstance(context.local())
11161 .ToLocalChecked();
11162 Local<v8::Object> o1 = t->GetFunction(context.local())
11163 .ToLocalChecked()
11164 ->NewInstance(context.local())
11165 .ToLocalChecked();
11166
11167 CHECK(o0->SetPrototype(context.local(), o1).FromJust())do { if ((__builtin_expect(!!(!(o0->SetPrototype(context.local
(), o1).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11167, "Check failed: %s.", "o0->SetPrototype(context.local(), o1).FromJust()"
); } } while (0)
;
11168 // If setting the prototype leads to the cycle, SetPrototype should
11169 // return false and keep VM in sane state.
11170 v8::TryCatch try_catch(isolate);
11171 CHECK(o1->SetPrototype(context.local(), o0).IsNothing())do { if ((__builtin_expect(!!(!(o1->SetPrototype(context.local
(), o0).IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11171, "Check failed: %s.", "o1->SetPrototype(context.local(), o0).IsNothing()"
); } } while (0)
;
11172 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11172, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11173 CHECK(!CcTest::i_isolate()->has_pending_exception())do { if ((__builtin_expect(!!(!(!CcTest::i_isolate()->has_pending_exception
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11173, "Check failed: %s."
, "!CcTest::i_isolate()->has_pending_exception()"); } } while
(0)
;
11174
11175 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("function f() { return 42; }; f()") ->Int32Value
(context.local()) .FromJust()), "42" " " "==" " " "CompileRun(\"function f() { return 42; }; f()\") ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11177, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11176 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("function f() { return 42; }; f()") ->Int32Value
(context.local()) .FromJust()), "42" " " "==" " " "CompileRun(\"function f() { return 42; }; f()\") ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11177, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11177 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
CompileRun("function f() { return 42; }; f()") ->Int32Value
(context.local()) .FromJust()), "42" " " "==" " " "CompileRun(\"function f() { return 42; }; f()\") ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11177, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11178}
11179
11180
11181THREADED_TEST(FunctionRemovePrototype)static void TestFunctionRemovePrototype(); RegisterThreadedTest
register_FunctionRemovePrototype(TestFunctionRemovePrototype
, "FunctionRemovePrototype"); static void TestFunctionRemovePrototype
(); CcTest register_test_FunctionRemovePrototype(TestFunctionRemovePrototype
, "../test/cctest/test-api.cc", "FunctionRemovePrototype", __null
, true, true); static void TestFunctionRemovePrototype()
{
11182 LocalContext context;
11183 v8::Isolate* isolate = context->GetIsolate();
11184 v8::HandleScope handle_scope(isolate);
11185
11186 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
11187 t1->RemovePrototype();
11188 Local<v8::Function> fun = t1->GetFunction(context.local()).ToLocalChecked();
11189 CHECK(context->Global()->Set(context.local(), v8_str("fun"), fun).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("fun"), fun).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11189, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"fun\"), fun).FromJust()"
); } } while (0)
;
11190 CHECK(!CompileRun("'prototype' in fun")do { if ((__builtin_expect(!!(!(!CompileRun("'prototype' in fun"
) ->BooleanValue(context.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11192, "Check failed: %s.", "!CompileRun(\"'prototype' in fun\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11191 ->BooleanValue(context.local())do { if ((__builtin_expect(!!(!(!CompileRun("'prototype' in fun"
) ->BooleanValue(context.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11192, "Check failed: %s.", "!CompileRun(\"'prototype' in fun\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
11192 .FromJust())do { if ((__builtin_expect(!!(!(!CompileRun("'prototype' in fun"
) ->BooleanValue(context.local()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11192, "Check failed: %s.", "!CompileRun(\"'prototype' in fun\") ->BooleanValue(context.local()) .FromJust()"
); } } while (0)
;
11193
11194 v8::TryCatch try_catch(isolate);
11195 CompileRun("new fun()");
11196 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11196, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11197
11198 try_catch.Reset();
11199 CHECK(fun->NewInstance(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(fun->NewInstance(context.local
()).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11199, "Check failed: %s.", "fun->NewInstance(context.local()).IsEmpty()"
); } } while (0)
;
11200 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11200, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11201}
11202
11203
11204THREADED_TEST(GetterSetterExceptions)static void TestGetterSetterExceptions(); RegisterThreadedTest
register_GetterSetterExceptions(TestGetterSetterExceptions, "GetterSetterExceptions"
); static void TestGetterSetterExceptions(); CcTest register_test_GetterSetterExceptions
(TestGetterSetterExceptions, "../test/cctest/test-api.cc", "GetterSetterExceptions"
, __null, true, true); static void TestGetterSetterExceptions
()
{
11205 LocalContext context;
11206 v8::Isolate* isolate = context->GetIsolate();
11207 v8::HandleScope handle_scope(isolate);
11208 CompileRun(
11209 "function Foo() { };"
11210 "function Throw() { throw 5; };"
11211 "var x = { };"
11212 "x.__defineSetter__('set', Throw);"
11213 "x.__defineGetter__('get', Throw);");
11214 Local<v8::Object> x = Local<v8::Object>::Cast(
11215 context->Global()->Get(context.local(), v8_str("x")).ToLocalChecked());
11216 v8::TryCatch try_catch(isolate);
11217 CHECK(x->Set(context.local(), v8_str("set"), v8::Integer::New(isolate, 8))do { if ((__builtin_expect(!!(!(x->Set(context.local(), v8_str
("set"), v8::Integer::New(isolate, 8)) .IsNothing())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11218, "Check failed: %s."
, "x->Set(context.local(), v8_str(\"set\"), v8::Integer::New(isolate, 8)) .IsNothing()"
); } } while (0)
11218 .IsNothing())do { if ((__builtin_expect(!!(!(x->Set(context.local(), v8_str
("set"), v8::Integer::New(isolate, 8)) .IsNothing())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11218, "Check failed: %s."
, "x->Set(context.local(), v8_str(\"set\"), v8::Integer::New(isolate, 8)) .IsNothing()"
); } } while (0)
;
11219 CHECK(x->Get(context.local(), v8_str("get")).IsEmpty())do { if ((__builtin_expect(!!(!(x->Get(context.local(), v8_str
("get")).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11219, "Check failed: %s.", "x->Get(context.local(), v8_str(\"get\")).IsEmpty()"
); } } while (0)
;
11220 CHECK(x->Set(context.local(), v8_str("set"), v8::Integer::New(isolate, 8))do { if ((__builtin_expect(!!(!(x->Set(context.local(), v8_str
("set"), v8::Integer::New(isolate, 8)) .IsNothing())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11221, "Check failed: %s."
, "x->Set(context.local(), v8_str(\"set\"), v8::Integer::New(isolate, 8)) .IsNothing()"
); } } while (0)
11221 .IsNothing())do { if ((__builtin_expect(!!(!(x->Set(context.local(), v8_str
("set"), v8::Integer::New(isolate, 8)) .IsNothing())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11221, "Check failed: %s."
, "x->Set(context.local(), v8_str(\"set\"), v8::Integer::New(isolate, 8)) .IsNothing()"
); } } while (0)
;
11222 CHECK(x->Get(context.local(), v8_str("get")).IsEmpty())do { if ((__builtin_expect(!!(!(x->Get(context.local(), v8_str
("get")).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11222, "Check failed: %s.", "x->Get(context.local(), v8_str(\"get\")).IsEmpty()"
); } } while (0)
;
11223 CHECK(x->Set(context.local(), v8_str("set"), v8::Integer::New(isolate, 8))do { if ((__builtin_expect(!!(!(x->Set(context.local(), v8_str
("set"), v8::Integer::New(isolate, 8)) .IsNothing())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11224, "Check failed: %s."
, "x->Set(context.local(), v8_str(\"set\"), v8::Integer::New(isolate, 8)) .IsNothing()"
); } } while (0)
11224 .IsNothing())do { if ((__builtin_expect(!!(!(x->Set(context.local(), v8_str
("set"), v8::Integer::New(isolate, 8)) .IsNothing())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11224, "Check failed: %s."
, "x->Set(context.local(), v8_str(\"set\"), v8::Integer::New(isolate, 8)) .IsNothing()"
); } } while (0)
;
11225 CHECK(x->Get(context.local(), v8_str("get")).IsEmpty())do { if ((__builtin_expect(!!(!(x->Get(context.local(), v8_str
("get")).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11225, "Check failed: %s.", "x->Get(context.local(), v8_str(\"get\")).IsEmpty()"
); } } while (0)
;
11226 CHECK(x->Set(context.local(), v8_str("set"), v8::Integer::New(isolate, 8))do { if ((__builtin_expect(!!(!(x->Set(context.local(), v8_str
("set"), v8::Integer::New(isolate, 8)) .IsNothing())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11227, "Check failed: %s."
, "x->Set(context.local(), v8_str(\"set\"), v8::Integer::New(isolate, 8)) .IsNothing()"
); } } while (0)
11227 .IsNothing())do { if ((__builtin_expect(!!(!(x->Set(context.local(), v8_str
("set"), v8::Integer::New(isolate, 8)) .IsNothing())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11227, "Check failed: %s."
, "x->Set(context.local(), v8_str(\"set\"), v8::Integer::New(isolate, 8)) .IsNothing()"
); } } while (0)
;
11228 CHECK(x->Get(context.local(), v8_str("get")).IsEmpty())do { if ((__builtin_expect(!!(!(x->Get(context.local(), v8_str
("get")).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11228, "Check failed: %s.", "x->Get(context.local(), v8_str(\"get\")).IsEmpty()"
); } } while (0)
;
11229}
11230
11231
11232THREADED_TEST(Constructor)static void TestConstructor(); RegisterThreadedTest register_Constructor
(TestConstructor, "Constructor"); static void TestConstructor
(); CcTest register_test_Constructor(TestConstructor, "../test/cctest/test-api.cc"
, "Constructor", __null, true, true); static void TestConstructor
()
{
11233 LocalContext context;
11234 v8::Isolate* isolate = context->GetIsolate();
11235 v8::HandleScope handle_scope(isolate);
11236 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
11237 templ->SetClassName(v8_str("Fun"));
11238 Local<Function> cons = templ->GetFunction(context.local()).ToLocalChecked();
11239 CHECK(do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("Fun"), cons).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11240, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"Fun\"), cons).FromJust()"
); } } while (0)
11240 context->Global()->Set(context.local(), v8_str("Fun"), cons).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("Fun"), cons).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11240, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"Fun\"), cons).FromJust()"
); } } while (0)
;
11241 Local<v8::Object> inst = cons->NewInstance(context.local()).ToLocalChecked();
11242 i::Handle<i::JSReceiver> obj(v8::Utils::OpenHandle(*inst));
11243 CHECK(obj->IsJSObject())do { if ((__builtin_expect(!!(!(obj->IsJSObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11243, "Check failed: %s."
, "obj->IsJSObject()"); } } while (0)
;
11244 Local<Value> value = CompileRun("(new Fun()).constructor === Fun");
11245 CHECK(value->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(value->BooleanValue(context
.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11245, "Check failed: %s.", "value->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
11246}
11247
11248
11249static void ConstructorCallback(
11250 const v8::FunctionCallbackInfo<v8::Value>& args) {
11251 ApiTestFuzzer::Fuzz();
11252 Local<Object> This;
11253
11254 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
11255 if (args.IsConstructCall()) {
11256 Local<Object> Holder = args.Holder();
11257 This = Object::New(args.GetIsolate());
11258 Local<Value> proto = Holder->GetPrototype();
11259 if (proto->IsObject()) {
11260 This->SetPrototype(context, proto).FromJust();
11261 }
11262 } else {
11263 This = args.This();
11264 }
11265
11266 This->Set(context, v8_str("a"), args[0]).FromJust();
11267 args.GetReturnValue().Set(This);
11268}
11269
11270
11271static void FakeConstructorCallback(
11272 const v8::FunctionCallbackInfo<v8::Value>& args) {
11273 ApiTestFuzzer::Fuzz();
11274 args.GetReturnValue().Set(args[0]);
11275}
11276
11277
11278THREADED_TEST(ConstructorForObject)static void TestConstructorForObject(); RegisterThreadedTest register_ConstructorForObject
(TestConstructorForObject, "ConstructorForObject"); static void
TestConstructorForObject(); CcTest register_test_ConstructorForObject
(TestConstructorForObject, "../test/cctest/test-api.cc", "ConstructorForObject"
, __null, true, true); static void TestConstructorForObject()
{
11279 LocalContext context;
11280 v8::Isolate* isolate = context->GetIsolate();
11281 v8::HandleScope handle_scope(isolate);
11282
11283 {
11284 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
11285 instance_template->SetCallAsFunctionHandler(ConstructorCallback);
11286 Local<Object> instance =
11287 instance_template->NewInstance(context.local()).ToLocalChecked();
11288 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), instance) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11290, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj\"), instance) .FromJust()"
); } } while (0)
11289 ->Set(context.local(), v8_str("obj"), instance)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), instance) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11290, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj\"), instance) .FromJust()"
); } } while (0)
11290 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), instance) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11290, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj\"), instance) .FromJust()"
); } } while (0)
;
11291 v8::TryCatch try_catch(isolate);
11292 Local<Value> value;
11293 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11293, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11294
11295 // Call the Object's constructor with a 32-bit signed integer.
11296 value = CompileRun("(function() { var o = new obj(28); return o.a; })()");
11297 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11297, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11298 CHECK(value->IsInt32())do { if ((__builtin_expect(!!(!(value->IsInt32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11298, "Check failed: %s."
, "value->IsInt32()"); } } while (0)
;
11299 CHECK_EQ(28, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (28), (
value->Int32Value(context.local()).FromJust()), "28" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11299, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11300
11301 Local<Value> args1[] = {v8_num(28)};
11302 Local<Value> value_obj1 =
11303 instance->CallAsConstructor(context.local(), 1, args1).ToLocalChecked();
11304 CHECK(value_obj1->IsObject())do { if ((__builtin_expect(!!(!(value_obj1->IsObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11304, "Check failed: %s."
, "value_obj1->IsObject()"); } } while (0)
;
11305 Local<Object> object1 = Local<Object>::Cast(value_obj1);
11306 value = object1->Get(context.local(), v8_str("a")).ToLocalChecked();
11307 CHECK(value->IsInt32())do { if ((__builtin_expect(!!(!(value->IsInt32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11307, "Check failed: %s."
, "value->IsInt32()"); } } while (0)
;
11308 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11308, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11309 CHECK_EQ(28, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (28), (
value->Int32Value(context.local()).FromJust()), "28" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11309, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11310
11311 // Call the Object's constructor with a String.
11312 value =
11313 CompileRun("(function() { var o = new obj('tipli'); return o.a; })()");
11314 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11314, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11315 CHECK(value->IsString())do { if ((__builtin_expect(!!(!(value->IsString())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11315, "Check failed: %s."
, "value->IsString()"); } } while (0)
;
11316 String::Utf8Value string_value1(
11317 value->ToString(context.local()).ToLocalChecked());
11318 CHECK_EQ(0, strcmp("tipli", *string_value1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("tipli", *string_value1)), "0" " " "==" " " "strcmp(\"tipli\", *string_value1)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11318, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11319
11320 Local<Value> args2[] = {v8_str("tipli")};
11321 Local<Value> value_obj2 =
11322 instance->CallAsConstructor(context.local(), 1, args2).ToLocalChecked();
11323 CHECK(value_obj2->IsObject())do { if ((__builtin_expect(!!(!(value_obj2->IsObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11323, "Check failed: %s."
, "value_obj2->IsObject()"); } } while (0)
;
11324 Local<Object> object2 = Local<Object>::Cast(value_obj2);
11325 value = object2->Get(context.local(), v8_str("a")).ToLocalChecked();
11326 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11326, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11327 CHECK(value->IsString())do { if ((__builtin_expect(!!(!(value->IsString())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11327, "Check failed: %s."
, "value->IsString()"); } } while (0)
;
11328 String::Utf8Value string_value2(
11329 value->ToString(context.local()).ToLocalChecked());
11330 CHECK_EQ(0, strcmp("tipli", *string_value2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("tipli", *string_value2)), "0" " " "==" " " "strcmp(\"tipli\", *string_value2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11330, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11331
11332 // Call the Object's constructor with a Boolean.
11333 value = CompileRun("(function() { var o = new obj(true); return o.a; })()");
11334 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11334, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11335 CHECK(value->IsBoolean())do { if ((__builtin_expect(!!(!(value->IsBoolean())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11335, "Check failed: %s."
, "value->IsBoolean()"); } } while (0)
;
11336 CHECK_EQ(true, value->BooleanValue(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (true),
(value->BooleanValue(context.local()).FromJust()), "true"
" " "==" " " "value->BooleanValue(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11336, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11337
11338 Local<Value> args3[] = {v8::True(isolate)};
11339 Local<Value> value_obj3 =
11340 instance->CallAsConstructor(context.local(), 1, args3).ToLocalChecked();
11341 CHECK(value_obj3->IsObject())do { if ((__builtin_expect(!!(!(value_obj3->IsObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11341, "Check failed: %s."
, "value_obj3->IsObject()"); } } while (0)
;
11342 Local<Object> object3 = Local<Object>::Cast(value_obj3);
11343 value = object3->Get(context.local(), v8_str("a")).ToLocalChecked();
11344 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11344, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11345 CHECK(value->IsBoolean())do { if ((__builtin_expect(!!(!(value->IsBoolean())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11345, "Check failed: %s."
, "value->IsBoolean()"); } } while (0)
;
11346 CHECK_EQ(true, value->BooleanValue(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (true),
(value->BooleanValue(context.local()).FromJust()), "true"
" " "==" " " "value->BooleanValue(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11346, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11347
11348 // Call the Object's constructor with undefined.
11349 Local<Value> args4[] = {v8::Undefined(isolate)};
11350 Local<Value> value_obj4 =
11351 instance->CallAsConstructor(context.local(), 1, args4).ToLocalChecked();
11352 CHECK(value_obj4->IsObject())do { if ((__builtin_expect(!!(!(value_obj4->IsObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11352, "Check failed: %s."
, "value_obj4->IsObject()"); } } while (0)
;
11353 Local<Object> object4 = Local<Object>::Cast(value_obj4);
11354 value = object4->Get(context.local(), v8_str("a")).ToLocalChecked();
11355 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11355, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11356 CHECK(value->IsUndefined())do { if ((__builtin_expect(!!(!(value->IsUndefined())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11356, "Check failed: %s."
, "value->IsUndefined()"); } } while (0)
;
11357
11358 // Call the Object's constructor with null.
11359 Local<Value> args5[] = {v8::Null(isolate)};
11360 Local<Value> value_obj5 =
11361 instance->CallAsConstructor(context.local(), 1, args5).ToLocalChecked();
11362 CHECK(value_obj5->IsObject())do { if ((__builtin_expect(!!(!(value_obj5->IsObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11362, "Check failed: %s."
, "value_obj5->IsObject()"); } } while (0)
;
11363 Local<Object> object5 = Local<Object>::Cast(value_obj5);
11364 value = object5->Get(context.local(), v8_str("a")).ToLocalChecked();
11365 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11365, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11366 CHECK(value->IsNull())do { if ((__builtin_expect(!!(!(value->IsNull())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11366, "Check failed: %s.", "value->IsNull()"
); } } while (0)
;
11367 }
11368
11369 // Check exception handling when there is no constructor set for the Object.
11370 {
11371 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
11372 Local<Object> instance =
11373 instance_template->NewInstance(context.local()).ToLocalChecked();
11374 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj2"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11376, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj2\"), instance) .FromJust()"
); } } while (0)
11375 ->Set(context.local(), v8_str("obj2"), instance)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj2"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11376, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj2\"), instance) .FromJust()"
); } } while (0)
11376 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj2"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11376, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj2\"), instance) .FromJust()"
); } } while (0)
;
11377 v8::TryCatch try_catch(isolate);
11378 Local<Value> value;
11379 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11379, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11380
11381 value = CompileRun("new obj2(28)");
11382 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11382, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11383 String::Utf8Value exception_value1(try_catch.Exception());
11384 CHECK_EQ(0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("TypeError: obj2 is not a constructor", *exception_value1)),
"0" " " "==" " " "strcmp(\"TypeError: obj2 is not a constructor\", *exception_value1)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11385, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11385 strcmp("TypeError: obj2 is not a constructor", *exception_value1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("TypeError: obj2 is not a constructor", *exception_value1)),
"0" " " "==" " " "strcmp(\"TypeError: obj2 is not a constructor\", *exception_value1)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11385, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11386 try_catch.Reset();
11387
11388 Local<Value> args[] = {v8_num(29)};
11389 CHECK(instance->CallAsConstructor(context.local(), 1, args).IsEmpty())do { if ((__builtin_expect(!!(!(instance->CallAsConstructor
(context.local(), 1, args).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11389, "Check failed: %s.", "instance->CallAsConstructor(context.local(), 1, args).IsEmpty()"
); } } while (0)
;
11390 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11390, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11391 String::Utf8Value exception_value2(try_catch.Exception());
11392 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("TypeError: object is not a constructor", *exception_value2)
), "0" " " "==" " " "strcmp(\"TypeError: object is not a constructor\", *exception_value2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11393, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11393 0, strcmp("TypeError: object is not a constructor", *exception_value2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("TypeError: object is not a constructor", *exception_value2)
), "0" " " "==" " " "strcmp(\"TypeError: object is not a constructor\", *exception_value2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11393, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11394 try_catch.Reset();
11395 }
11396
11397 // Check the case when constructor throws exception.
11398 {
11399 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
11400 instance_template->SetCallAsFunctionHandler(ThrowValue);
11401 Local<Object> instance =
11402 instance_template->NewInstance(context.local()).ToLocalChecked();
11403 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj3"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11405, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj3\"), instance) .FromJust()"
); } } while (0)
11404 ->Set(context.local(), v8_str("obj3"), instance)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj3"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11405, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj3\"), instance) .FromJust()"
); } } while (0)
11405 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj3"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11405, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj3\"), instance) .FromJust()"
); } } while (0)
;
11406 v8::TryCatch try_catch(isolate);
11407 Local<Value> value;
11408 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11408, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11409
11410 value = CompileRun("new obj3(22)");
11411 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11411, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11412 String::Utf8Value exception_value1(try_catch.Exception());
11413 CHECK_EQ(0, strcmp("22", *exception_value1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("22", *exception_value1)), "0" " " "==" " " "strcmp(\"22\", *exception_value1)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11413, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11414 try_catch.Reset();
11415
11416 Local<Value> args[] = {v8_num(23)};
11417 CHECK(instance->CallAsConstructor(context.local(), 1, args).IsEmpty())do { if ((__builtin_expect(!!(!(instance->CallAsConstructor
(context.local(), 1, args).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11417, "Check failed: %s.", "instance->CallAsConstructor(context.local(), 1, args).IsEmpty()"
); } } while (0)
;
11418 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11418, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11419 String::Utf8Value exception_value2(try_catch.Exception());
11420 CHECK_EQ(0, strcmp("23", *exception_value2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("23", *exception_value2)), "0" " " "==" " " "strcmp(\"23\", *exception_value2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11420, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11421 try_catch.Reset();
11422 }
11423
11424 // Check whether constructor returns with an object or non-object.
11425 {
11426 Local<FunctionTemplate> function_template =
11427 FunctionTemplate::New(isolate, FakeConstructorCallback);
11428 Local<Function> function =
11429 function_template->GetFunction(context.local()).ToLocalChecked();
11430 Local<Object> instance1 = function;
11431 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj4"), instance1) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11433, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj4\"), instance1) .FromJust()"
); } } while (0)
11432 ->Set(context.local(), v8_str("obj4"), instance1)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj4"), instance1) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11433, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj4\"), instance1) .FromJust()"
); } } while (0)
11433 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj4"), instance1) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11433, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj4\"), instance1) .FromJust()"
); } } while (0)
;
11434 v8::TryCatch try_catch(isolate);
11435 Local<Value> value;
11436 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11436, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11437
11438 CHECK(instance1->IsObject())do { if ((__builtin_expect(!!(!(instance1->IsObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11438, "Check failed: %s."
, "instance1->IsObject()"); } } while (0)
;
11439 CHECK(instance1->IsFunction())do { if ((__builtin_expect(!!(!(instance1->IsFunction())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 11439, "Check failed: %s."
, "instance1->IsFunction()"); } } while (0)
;
11440
11441 value = CompileRun("new obj4(28)");
11442 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11442, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11443 CHECK(value->IsObject())do { if ((__builtin_expect(!!(!(value->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11443, "Check failed: %s."
, "value->IsObject()"); } } while (0)
;
11444
11445 Local<Value> args1[] = {v8_num(28)};
11446 value = instance1->CallAsConstructor(context.local(), 1, args1)
11447 .ToLocalChecked();
11448 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11448, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11449 CHECK(value->IsObject())do { if ((__builtin_expect(!!(!(value->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11449, "Check failed: %s."
, "value->IsObject()"); } } while (0)
;
11450
11451 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
11452 instance_template->SetCallAsFunctionHandler(FakeConstructorCallback);
11453 Local<Object> instance2 =
11454 instance_template->NewInstance(context.local()).ToLocalChecked();
11455 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj5"), instance2) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11457, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj5\"), instance2) .FromJust()"
); } } while (0)
11456 ->Set(context.local(), v8_str("obj5"), instance2)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj5"), instance2) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11457, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj5\"), instance2) .FromJust()"
); } } while (0)
11457 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj5"), instance2) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11457, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj5\"), instance2) .FromJust()"
); } } while (0)
;
11458 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11458, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11459
11460 CHECK(instance2->IsObject())do { if ((__builtin_expect(!!(!(instance2->IsObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11460, "Check failed: %s."
, "instance2->IsObject()"); } } while (0)
;
11461 CHECK(instance2->IsFunction())do { if ((__builtin_expect(!!(!(instance2->IsFunction())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 11461, "Check failed: %s."
, "instance2->IsFunction()"); } } while (0)
;
11462
11463 value = CompileRun("new obj5(28)");
11464 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11464, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11465 CHECK(!value->IsObject())do { if ((__builtin_expect(!!(!(!value->IsObject())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11465, "Check failed: %s."
, "!value->IsObject()"); } } while (0)
;
11466
11467 Local<Value> args2[] = {v8_num(28)};
11468 value = instance2->CallAsConstructor(context.local(), 1, args2)
11469 .ToLocalChecked();
11470 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11470, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11471 CHECK(!value->IsObject())do { if ((__builtin_expect(!!(!(!value->IsObject())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11471, "Check failed: %s."
, "!value->IsObject()"); } } while (0)
;
11472 }
11473}
11474
11475
11476THREADED_TEST(FunctionDescriptorException)static void TestFunctionDescriptorException(); RegisterThreadedTest
register_FunctionDescriptorException(TestFunctionDescriptorException
, "FunctionDescriptorException"); static void TestFunctionDescriptorException
(); CcTest register_test_FunctionDescriptorException(TestFunctionDescriptorException
, "../test/cctest/test-api.cc", "FunctionDescriptorException"
, __null, true, true); static void TestFunctionDescriptorException
()
{
11477 LocalContext context;
11478 v8::Isolate* isolate = context->GetIsolate();
11479 v8::HandleScope handle_scope(isolate);
11480 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
11481 templ->SetClassName(v8_str("Fun"));
11482 Local<Function> cons = templ->GetFunction(context.local()).ToLocalChecked();
11483 CHECK(do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("Fun"), cons).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11484, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"Fun\"), cons).FromJust()"
); } } while (0)
11484 context->Global()->Set(context.local(), v8_str("Fun"), cons).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("Fun"), cons).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11484, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"Fun\"), cons).FromJust()"
); } } while (0)
;
11485 Local<Value> value = CompileRun(
11486 "function test() {"
11487 " try {"
11488 " (new Fun()).blah()"
11489 " } catch (e) {"
11490 " var str = String(e);"
11491 // " if (str.indexOf('TypeError') == -1) return 1;"
11492 // " if (str.indexOf('[object Fun]') != -1) return 2;"
11493 // " if (str.indexOf('#<Fun>') == -1) return 3;"
11494 " return 0;"
11495 " }"
11496 " return 4;"
11497 "}"
11498 "test();");
11499 CHECK_EQ(0, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (value
->Int32Value(context.local()).FromJust()), "0" " " "==" " "
"value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11499, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11500}
11501
11502
11503THREADED_TEST(EvalAliasedDynamic)static void TestEvalAliasedDynamic(); RegisterThreadedTest register_EvalAliasedDynamic
(TestEvalAliasedDynamic, "EvalAliasedDynamic"); static void TestEvalAliasedDynamic
(); CcTest register_test_EvalAliasedDynamic(TestEvalAliasedDynamic
, "../test/cctest/test-api.cc", "EvalAliasedDynamic", __null,
true, true); static void TestEvalAliasedDynamic()
{
11504 LocalContext current;
11505 v8::HandleScope scope(current->GetIsolate());
11506
11507 // Tests where aliased eval can only be resolved dynamically.
11508 Local<Script> script = v8_compile(
11509 "function f(x) { "
11510 " var foo = 2;"
11511 " with (x) { return eval('foo'); }"
11512 "}"
11513 "foo = 0;"
11514 "result1 = f(new Object());"
11515 "result2 = f(this);"
11516 "var x = new Object();"
11517 "x.eval = function(x) { return 1; };"
11518 "result3 = f(x);");
11519 script->Run(current.local()).ToLocalChecked();
11520 CHECK_EQ(2, current->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result1")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result1\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11524, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11521 ->Get(current.local(), v8_str("result1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result1")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result1\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11524, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11522 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result1")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result1\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11524, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11523 ->Int32Value(current.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result1")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result1\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11524, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11524 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result1")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result1\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11524, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11525 CHECK_EQ(0, current->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (current
->Global() ->Get(current.local(), v8_str("result2")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "0" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result2\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11529, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11526 ->Get(current.local(), v8_str("result2"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (current
->Global() ->Get(current.local(), v8_str("result2")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "0" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result2\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11529, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11527 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (current
->Global() ->Get(current.local(), v8_str("result2")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "0" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result2\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11529, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11528 ->Int32Value(current.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (current
->Global() ->Get(current.local(), v8_str("result2")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "0" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result2\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11529, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11529 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (current
->Global() ->Get(current.local(), v8_str("result2")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "0" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result2\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11529, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11530 CHECK_EQ(1, current->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (current
->Global() ->Get(current.local(), v8_str("result3")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "1" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result3\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11534, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11531 ->Get(current.local(), v8_str("result3"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (current
->Global() ->Get(current.local(), v8_str("result3")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "1" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result3\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11534, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11532 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (current
->Global() ->Get(current.local(), v8_str("result3")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "1" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result3\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11534, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11533 ->Int32Value(current.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (current
->Global() ->Get(current.local(), v8_str("result3")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "1" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result3\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11534, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11534 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (current
->Global() ->Get(current.local(), v8_str("result3")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "1" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result3\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11534, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11535
11536 v8::TryCatch try_catch(current->GetIsolate());
11537 script = v8_compile(
11538 "function f(x) { "
11539 " var bar = 2;"
11540 " with (x) { return eval('bar'); }"
11541 "}"
11542 "result4 = f(this)");
11543 script->Run(current.local()).ToLocalChecked();
11544 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11544, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11545 CHECK_EQ(2, current->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result4")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result4\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11549, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11546 ->Get(current.local(), v8_str("result4"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result4")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result4\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11549, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11547 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result4")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result4\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11549, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11548 ->Int32Value(current.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result4")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result4\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11549, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11549 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (current
->Global() ->Get(current.local(), v8_str("result4")) .ToLocalChecked
() ->Int32Value(current.local()) .FromJust()), "2" " " "=="
" " "current->Global() ->Get(current.local(), v8_str(\"result4\")) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11549, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11550
11551 try_catch.Reset();
11552}
11553
11554
11555THREADED_TEST(CrossEval)static void TestCrossEval(); RegisterThreadedTest register_CrossEval
(TestCrossEval, "CrossEval"); static void TestCrossEval(); CcTest
register_test_CrossEval(TestCrossEval, "../test/cctest/test-api.cc"
, "CrossEval", __null, true, true); static void TestCrossEval
()
{
11556 v8::HandleScope scope(CcTest::isolate());
11557 LocalContext other;
11558 LocalContext current;
11559
11560 Local<String> token = v8_str("<security token>");
11561 other->SetSecurityToken(token);
11562 current->SetSecurityToken(token);
11563
11564 // Set up reference from current to other.
11565 CHECK(current->Global()do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11567, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
11566 ->Set(current.local(), v8_str("other"), other->Global())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11567, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
11567 .FromJust())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11567, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
;
11568
11569 // Check that new variables are introduced in other context.
11570 Local<Script> script = v8_compile("other.eval('var foo = 1234')");
11571 script->Run(current.local()).ToLocalChecked();
11572 Local<Value> foo =
11573 other->Global()->Get(current.local(), v8_str("foo")).ToLocalChecked();
11574 CHECK_EQ(1234, foo->Int32Value(other.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(foo->Int32Value(other.local()).FromJust()), "1234" " " "=="
" " "foo->Int32Value(other.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11574, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11575 CHECK(!current->Global()->Has(current.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(!current->Global()->Has
(current.local(), v8_str("foo")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11575, "Check failed: %s.", "!current->Global()->Has(current.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
11576
11577 // Check that writing to non-existing properties introduces them in
11578 // the other context.
11579 script = v8_compile("other.eval('na = 1234')");
11580 script->Run(current.local()).ToLocalChecked();
11581 CHECK_EQ(1234, other->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(other->Global() ->Get(current.local(), v8_str("na")) .
ToLocalChecked() ->Int32Value(other.local()) .FromJust()),
"1234" " " "==" " " "other->Global() ->Get(current.local(), v8_str(\"na\")) .ToLocalChecked() ->Int32Value(other.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11585, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11582 ->Get(current.local(), v8_str("na"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(other->Global() ->Get(current.local(), v8_str("na")) .
ToLocalChecked() ->Int32Value(other.local()) .FromJust()),
"1234" " " "==" " " "other->Global() ->Get(current.local(), v8_str(\"na\")) .ToLocalChecked() ->Int32Value(other.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11585, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11583 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(other->Global() ->Get(current.local(), v8_str("na")) .
ToLocalChecked() ->Int32Value(other.local()) .FromJust()),
"1234" " " "==" " " "other->Global() ->Get(current.local(), v8_str(\"na\")) .ToLocalChecked() ->Int32Value(other.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11585, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11584 ->Int32Value(other.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(other->Global() ->Get(current.local(), v8_str("na")) .
ToLocalChecked() ->Int32Value(other.local()) .FromJust()),
"1234" " " "==" " " "other->Global() ->Get(current.local(), v8_str(\"na\")) .ToLocalChecked() ->Int32Value(other.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11585, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11585 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(other->Global() ->Get(current.local(), v8_str("na")) .
ToLocalChecked() ->Int32Value(other.local()) .FromJust()),
"1234" " " "==" " " "other->Global() ->Get(current.local(), v8_str(\"na\")) .ToLocalChecked() ->Int32Value(other.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11585, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11586 CHECK(!current->Global()->Has(current.local(), v8_str("na")).FromJust())do { if ((__builtin_expect(!!(!(!current->Global()->Has
(current.local(), v8_str("na")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11586, "Check failed: %s.", "!current->Global()->Has(current.local(), v8_str(\"na\")).FromJust()"
); } } while (0)
;
11587
11588 // Check that global variables in current context are not visible in other
11589 // context.
11590 v8::TryCatch try_catch(CcTest::isolate());
11591 script = v8_compile("var bar = 42; other.eval('bar');");
11592 CHECK(script->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(current.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
11592, "Check failed: %s.", "script->Run(current.local()).IsEmpty()"
); } } while (0)
;
11593 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11593, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11594 try_catch.Reset();
11595
11596 // Check that local variables in current context are not visible in other
11597 // context.
11598 script = v8_compile(
11599 "(function() { "
11600 " var baz = 87;"
11601 " return other.eval('baz');"
11602 "})();");
11603 CHECK(script->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(current.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
11603, "Check failed: %s.", "script->Run(current.local()).IsEmpty()"
); } } while (0)
;
11604 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11604, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11605 try_catch.Reset();
11606
11607 // Check that global variables in the other environment are visible
11608 // when evaluting code.
11609 CHECK(other->Global()do { if ((__builtin_expect(!!(!(other->Global() ->Set(other
.local(), v8_str("bis"), v8_num(1234)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11611, "Check failed: %s.", "other->Global() ->Set(other.local(), v8_str(\"bis\"), v8_num(1234)) .FromJust()"
); } } while (0)
11610 ->Set(other.local(), v8_str("bis"), v8_num(1234))do { if ((__builtin_expect(!!(!(other->Global() ->Set(other
.local(), v8_str("bis"), v8_num(1234)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11611, "Check failed: %s.", "other->Global() ->Set(other.local(), v8_str(\"bis\"), v8_num(1234)) .FromJust()"
); } } while (0)
11611 .FromJust())do { if ((__builtin_expect(!!(!(other->Global() ->Set(other
.local(), v8_str("bis"), v8_num(1234)) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11611, "Check failed: %s.", "other->Global() ->Set(other.local(), v8_str(\"bis\"), v8_num(1234)) .FromJust()"
); } } while (0)
;
11612 script = v8_compile("other.eval('bis')");
11613 CHECK_EQ(1234, script->Run(current.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script->Run(current.local()) .ToLocalChecked() ->Int32Value
(current.local()) .FromJust()), "1234" " " "==" " " "script->Run(current.local()) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11616, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11614 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script->Run(current.local()) .ToLocalChecked() ->Int32Value
(current.local()) .FromJust()), "1234" " " "==" " " "script->Run(current.local()) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11616, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11615 ->Int32Value(current.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script->Run(current.local()) .ToLocalChecked() ->Int32Value
(current.local()) .FromJust()), "1234" " " "==" " " "script->Run(current.local()) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11616, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11616 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script->Run(current.local()) .ToLocalChecked() ->Int32Value
(current.local()) .FromJust()), "1234" " " "==" " " "script->Run(current.local()) .ToLocalChecked() ->Int32Value(current.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11616, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11617 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11617, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11618
11619 // Check that the 'this' pointer points to the global object evaluating
11620 // code.
11621 CHECK(other->Global()do { if ((__builtin_expect(!!(!(other->Global() ->Set(current
.local(), v8_str("t"), other->Global()) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11623, "Check failed: %s."
, "other->Global() ->Set(current.local(), v8_str(\"t\"), other->Global()) .FromJust()"
); } } while (0)
11622 ->Set(current.local(), v8_str("t"), other->Global())do { if ((__builtin_expect(!!(!(other->Global() ->Set(current
.local(), v8_str("t"), other->Global()) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11623, "Check failed: %s."
, "other->Global() ->Set(current.local(), v8_str(\"t\"), other->Global()) .FromJust()"
); } } while (0)
11623 .FromJust())do { if ((__builtin_expect(!!(!(other->Global() ->Set(current
.local(), v8_str("t"), other->Global()) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11623, "Check failed: %s."
, "other->Global() ->Set(current.local(), v8_str(\"t\"), other->Global()) .FromJust()"
); } } while (0)
;
11624 script = v8_compile("other.eval('this == t')");
11625 Local<Value> result = script->Run(current.local()).ToLocalChecked();
11626 CHECK(result->IsTrue())do { if ((__builtin_expect(!!(!(result->IsTrue())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11626, "Check failed: %s."
, "result->IsTrue()"); } } while (0)
;
11627 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11627, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11628
11629 // Check that variables introduced in with-statement are not visible in
11630 // other context.
11631 script = v8_compile("with({x:2}){other.eval('x')}");
11632 CHECK(script->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(current.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
11632, "Check failed: %s.", "script->Run(current.local()).IsEmpty()"
); } } while (0)
;
11633 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11633, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11634 try_catch.Reset();
11635
11636 // Check that you cannot use 'eval.call' with another object than the
11637 // current global object.
11638 script = v8_compile("other.y = 1; eval.call(other, 'y')");
11639 CHECK(script->Run(current.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(current.local(
)).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
11639, "Check failed: %s.", "script->Run(current.local()).IsEmpty()"
); } } while (0)
;
11640 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11640, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11641}
11642
11643
11644// Test that calling eval in a context which has been detached from
11645// its global proxy works.
11646THREADED_TEST(EvalInDetachedGlobal)static void TestEvalInDetachedGlobal(); RegisterThreadedTest register_EvalInDetachedGlobal
(TestEvalInDetachedGlobal, "EvalInDetachedGlobal"); static void
TestEvalInDetachedGlobal(); CcTest register_test_EvalInDetachedGlobal
(TestEvalInDetachedGlobal, "../test/cctest/test-api.cc", "EvalInDetachedGlobal"
, __null, true, true); static void TestEvalInDetachedGlobal()
{
11647 v8::Isolate* isolate = CcTest::isolate();
11648 v8::HandleScope scope(isolate);
11649
11650 v8::Local<Context> context0 = Context::New(isolate);
11651 v8::Local<Context> context1 = Context::New(isolate);
11652
11653 // Set up function in context0 that uses eval from context0.
11654 context0->Enter();
11655 v8::Local<v8::Value> fun = CompileRun(
11656 "var x = 42;"
11657 "(function() {"
11658 " var e = eval;"
11659 " return function(s) { return e(s); }"
11660 "})()");
11661 context0->Exit();
11662
11663 // Put the function into context1 and call it before and after
11664 // detaching the global. Before detaching, the call succeeds and
11665 // after detaching and exception is thrown.
11666 context1->Enter();
11667 CHECK(context1->Global()->Set(context1, v8_str("fun"), fun).FromJust())do { if ((__builtin_expect(!!(!(context1->Global()->Set
(context1, v8_str("fun"), fun).FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 11667, "Check failed: %s.", "context1->Global()->Set(context1, v8_str(\"fun\"), fun).FromJust()"
); } } while (0)
;
11668 v8::Local<v8::Value> x_value = CompileRun("fun('x')");
11669 CHECK_EQ(42, x_value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
x_value->Int32Value(context1).FromJust()), "42" " " "==" " "
"x_value->Int32Value(context1).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 11669, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
11670 context0->DetachGlobal();
11671 v8::TryCatch catcher(isolate);
11672 x_value = CompileRun("fun('x')");
11673 CHECK_EQ(42, x_value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
x_value->Int32Value(context1).FromJust()), "42" " " "==" " "
"x_value->Int32Value(context1).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 11673, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
11674 context1->Exit();
11675}
11676
11677
11678THREADED_TEST(CrossLazyLoad)static void TestCrossLazyLoad(); RegisterThreadedTest register_CrossLazyLoad
(TestCrossLazyLoad, "CrossLazyLoad"); static void TestCrossLazyLoad
(); CcTest register_test_CrossLazyLoad(TestCrossLazyLoad, "../test/cctest/test-api.cc"
, "CrossLazyLoad", __null, true, true); static void TestCrossLazyLoad
()
{
11679 v8::HandleScope scope(CcTest::isolate());
11680 LocalContext other;
11681 LocalContext current;
11682
11683 Local<String> token = v8_str("<security token>");
11684 other->SetSecurityToken(token);
11685 current->SetSecurityToken(token);
11686
11687 // Set up reference from current to other.
11688 CHECK(current->Global()do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11690, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
11689 ->Set(current.local(), v8_str("other"), other->Global())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11690, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
11690 .FromJust())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("other"), other->Global()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11690, "Check failed: %s."
, "current->Global() ->Set(current.local(), v8_str(\"other\"), other->Global()) .FromJust()"
); } } while (0)
;
11691
11692 // Trigger lazy loading in other context.
11693 Local<Script> script = v8_compile("other.eval('new Date(42)')");
11694 Local<Value> value = script->Run(current.local()).ToLocalChecked();
11695 CHECK_EQ(42.0, value->NumberValue(current.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(value->NumberValue(current.local()).FromJust()), "42.0" " "
"==" " " "value->NumberValue(current.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 11695, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11696}
11697
11698
11699static void call_as_function(const v8::FunctionCallbackInfo<v8::Value>& args) {
11700 ApiTestFuzzer::Fuzz();
11701 if (args.IsConstructCall()) {
11702 if (args[0]->IsInt32()) {
11703 args.GetReturnValue().Set(
11704 v8_num(-args[0]
11705 ->Int32Value(args.GetIsolate()->GetCurrentContext())
11706 .FromJust()));
11707 return;
11708 }
11709 }
11710
11711 args.GetReturnValue().Set(args[0]);
11712}
11713
11714
11715static void ReturnThis(const v8::FunctionCallbackInfo<v8::Value>& args) {
11716 args.GetReturnValue().Set(args.This());
11717}
11718
11719
11720// Test that a call handler can be set for objects which will allow
11721// non-function objects created through the API to be called as
11722// functions.
11723THREADED_TEST(CallAsFunction)static void TestCallAsFunction(); RegisterThreadedTest register_CallAsFunction
(TestCallAsFunction, "CallAsFunction"); static void TestCallAsFunction
(); CcTest register_test_CallAsFunction(TestCallAsFunction, "../test/cctest/test-api.cc"
, "CallAsFunction", __null, true, true); static void TestCallAsFunction
()
{
11724 LocalContext context;
11725 v8::Isolate* isolate = context->GetIsolate();
11726 v8::HandleScope scope(isolate);
11727
11728 {
11729 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
11730 Local<ObjectTemplate> instance_template = t->InstanceTemplate();
11731 instance_template->SetCallAsFunctionHandler(call_as_function);
11732 Local<v8::Object> instance = t->GetFunction(context.local())
11733 .ToLocalChecked()
11734 ->NewInstance(context.local())
11735 .ToLocalChecked();
11736 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), instance) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11738, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj\"), instance) .FromJust()"
); } } while (0)
11737 ->Set(context.local(), v8_str("obj"), instance)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), instance) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11738, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj\"), instance) .FromJust()"
); } } while (0)
11738 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), instance) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11738, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj\"), instance) .FromJust()"
); } } while (0)
;
11739 v8::TryCatch try_catch(isolate);
11740 Local<Value> value;
11741 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11741, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11742
11743 value = CompileRun("obj(42)");
11744 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11744, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11745 CHECK_EQ(42, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11745, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11746
11747 value = CompileRun("(function(o){return o(49)})(obj)");
11748 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11748, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11749 CHECK_EQ(49, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (49), (
value->Int32Value(context.local()).FromJust()), "49" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11749, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11750
11751 // test special case of call as function
11752 value = CompileRun("[obj]['0'](45)");
11753 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11753, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11754 CHECK_EQ(45, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (45), (
value->Int32Value(context.local()).FromJust()), "45" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11754, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11755
11756 value = CompileRun(
11757 "obj.call = Function.prototype.call;"
11758 "obj.call(null, 87)");
11759 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11759, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11760 CHECK_EQ(87, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (87), (
value->Int32Value(context.local()).FromJust()), "87" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11760, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11761
11762 // Regression tests for bug #1116356: Calling call through call/apply
11763 // must work for non-function receivers.
11764 const char* apply_99 = "Function.prototype.call.apply(obj, [this, 99])";
11765 value = CompileRun(apply_99);
11766 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11766, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11767 CHECK_EQ(99, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (99), (
value->Int32Value(context.local()).FromJust()), "99" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11767, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11768
11769 const char* call_17 = "Function.prototype.call.call(obj, this, 17)";
11770 value = CompileRun(call_17);
11771 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11771, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11772 CHECK_EQ(17, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17), (
value->Int32Value(context.local()).FromJust()), "17" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11772, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11773
11774 // Check that the call-as-function handler can be called through
11775 // new.
11776 value = CompileRun("new obj(43)");
11777 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11777, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11778 CHECK_EQ(-43, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-43), (
value->Int32Value(context.local()).FromJust()), "-43" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11778, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11779
11780 // Check that the call-as-function handler can be called through
11781 // the API.
11782 v8::Local<Value> args[] = {v8_num(28)};
11783 value = instance->CallAsFunction(context.local(), instance, 1, args)
11784 .ToLocalChecked();
11785 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11785, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11786 CHECK_EQ(28, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (28), (
value->Int32Value(context.local()).FromJust()), "28" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 11786, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11787 }
11788
11789 {
11790 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
11791 Local<ObjectTemplate> instance_template(t->InstanceTemplate());
11792 USE(instance_template);
11793 Local<v8::Object> instance = t->GetFunction(context.local())
11794 .ToLocalChecked()
11795 ->NewInstance(context.local())
11796 .ToLocalChecked();
11797 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj2"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11799, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj2\"), instance) .FromJust()"
); } } while (0)
11798 ->Set(context.local(), v8_str("obj2"), instance)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj2"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11799, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj2\"), instance) .FromJust()"
); } } while (0)
11799 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj2"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11799, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj2\"), instance) .FromJust()"
); } } while (0)
;
11800 v8::TryCatch try_catch(isolate);
11801 Local<Value> value;
11802 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11802, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11803
11804 // Call an object without call-as-function handler through the JS
11805 value = CompileRun("obj2(28)");
11806 CHECK(value.IsEmpty())do { if ((__builtin_expect(!!(!(value.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11806, "Check failed: %s.", "value.IsEmpty()"
); } } while (0)
;
11807 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11807, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11808 String::Utf8Value exception_value1(try_catch.Exception());
11809 // TODO(verwaest): Better message
11810 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("TypeError: obj2 is not a function", *exception_value1)), "0"
" " "==" " " "strcmp(\"TypeError: obj2 is not a function\", *exception_value1)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11810, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11811 try_catch.Reset();
11812
11813 // Call an object without call-as-function handler through the API
11814 value = CompileRun("obj2(28)");
11815 v8::Local<Value> args[] = {v8_num(28)};
11816 CHECK(do { if ((__builtin_expect(!!(!(instance->CallAsFunction(context
.local(), instance, 1, args).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11817, "Check failed: %s.", "instance->CallAsFunction(context.local(), instance, 1, args).IsEmpty()"
); } } while (0)
11817 instance->CallAsFunction(context.local(), instance, 1, args).IsEmpty())do { if ((__builtin_expect(!!(!(instance->CallAsFunction(context
.local(), instance, 1, args).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11817, "Check failed: %s.", "instance->CallAsFunction(context.local(), instance, 1, args).IsEmpty()"
); } } while (0)
;
11818 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11818, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11819 String::Utf8Value exception_value2(try_catch.Exception());
11820 CHECK_EQ(0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("TypeError: object is not a function", *exception_value2)), "0"
" " "==" " " "strcmp(\"TypeError: object is not a function\", *exception_value2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11821, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
11821 strcmp("TypeError: object is not a function", *exception_value2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("TypeError: object is not a function", *exception_value2)), "0"
" " "==" " " "strcmp(\"TypeError: object is not a function\", *exception_value2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11821, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11822 try_catch.Reset();
11823 }
11824
11825 {
11826 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
11827 Local<ObjectTemplate> instance_template = t->InstanceTemplate();
11828 instance_template->SetCallAsFunctionHandler(ThrowValue);
11829 Local<v8::Object> instance = t->GetFunction(context.local())
11830 .ToLocalChecked()
11831 ->NewInstance(context.local())
11832 .ToLocalChecked();
11833 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj3"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11835, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj3\"), instance) .FromJust()"
); } } while (0)
11834 ->Set(context.local(), v8_str("obj3"), instance)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj3"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11835, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj3\"), instance) .FromJust()"
); } } while (0)
11835 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj3"), instance) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11835, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj3\"), instance) .FromJust()"
); } } while (0)
;
11836 v8::TryCatch try_catch(isolate);
11837 Local<Value> value;
11838 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11838, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11839
11840 // Catch the exception which is thrown by call-as-function handler
11841 value = CompileRun("obj3(22)");
11842 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11842, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11843 String::Utf8Value exception_value1(try_catch.Exception());
11844 CHECK_EQ(0, strcmp("22", *exception_value1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("22", *exception_value1)), "0" " " "==" " " "strcmp(\"22\", *exception_value1)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11844, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11845 try_catch.Reset();
11846
11847 v8::Local<Value> args[] = {v8_num(23)};
11848 CHECK(do { if ((__builtin_expect(!!(!(instance->CallAsFunction(context
.local(), instance, 1, args).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11849, "Check failed: %s.", "instance->CallAsFunction(context.local(), instance, 1, args).IsEmpty()"
); } } while (0)
11849 instance->CallAsFunction(context.local(), instance, 1, args).IsEmpty())do { if ((__builtin_expect(!!(!(instance->CallAsFunction(context
.local(), instance, 1, args).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11849, "Check failed: %s.", "instance->CallAsFunction(context.local(), instance, 1, args).IsEmpty()"
); } } while (0)
;
11850 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 11850, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
11851 String::Utf8Value exception_value2(try_catch.Exception());
11852 CHECK_EQ(0, strcmp("23", *exception_value2))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("23", *exception_value2)), "0" " " "==" " " "strcmp(\"23\", *exception_value2)"
)) { V8_Fatal("../test/cctest/test-api.cc", 11852, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
11853 try_catch.Reset();
11854 }
11855
11856 {
11857 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
11858 Local<ObjectTemplate> instance_template = t->InstanceTemplate();
11859 instance_template->SetCallAsFunctionHandler(ReturnThis);
11860 Local<v8::Object> instance = t->GetFunction(context.local())
11861 .ToLocalChecked()
11862 ->NewInstance(context.local())
11863 .ToLocalChecked();
11864
11865 Local<v8::Value> a1 =
11866 instance->CallAsFunction(context.local(), v8::Undefined(isolate), 0,
11867 NULL__null)
11868 .ToLocalChecked();
11869 CHECK(a1->StrictEquals(instance))do { if ((__builtin_expect(!!(!(a1->StrictEquals(instance)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11869, "Check failed: %s."
, "a1->StrictEquals(instance)"); } } while (0)
;
11870 Local<v8::Value> a2 =
11871 instance->CallAsFunction(context.local(), v8::Null(isolate), 0, NULL__null)
11872 .ToLocalChecked();
11873 CHECK(a2->StrictEquals(instance))do { if ((__builtin_expect(!!(!(a2->StrictEquals(instance)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11873, "Check failed: %s."
, "a2->StrictEquals(instance)"); } } while (0)
;
11874 Local<v8::Value> a3 =
11875 instance->CallAsFunction(context.local(), v8_num(42), 0, NULL__null)
11876 .ToLocalChecked();
11877 CHECK(a3->StrictEquals(instance))do { if ((__builtin_expect(!!(!(a3->StrictEquals(instance)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11877, "Check failed: %s."
, "a3->StrictEquals(instance)"); } } while (0)
;
11878 Local<v8::Value> a4 =
11879 instance->CallAsFunction(context.local(), v8_str("hello"), 0, NULL__null)
11880 .ToLocalChecked();
11881 CHECK(a4->StrictEquals(instance))do { if ((__builtin_expect(!!(!(a4->StrictEquals(instance)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11881, "Check failed: %s."
, "a4->StrictEquals(instance)"); } } while (0)
;
11882 Local<v8::Value> a5 =
11883 instance->CallAsFunction(context.local(), v8::True(isolate), 0, NULL__null)
11884 .ToLocalChecked();
11885 CHECK(a5->StrictEquals(instance))do { if ((__builtin_expect(!!(!(a5->StrictEquals(instance)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11885, "Check failed: %s."
, "a5->StrictEquals(instance)"); } } while (0)
;
11886 }
11887
11888 {
11889 CompileRun(
11890 "function ReturnThisSloppy() {"
11891 " return this;"
11892 "}"
11893 "function ReturnThisStrict() {"
11894 " 'use strict';"
11895 " return this;"
11896 "}");
11897 Local<Function> ReturnThisSloppy = Local<Function>::Cast(
11898 context->Global()
11899 ->Get(context.local(), v8_str("ReturnThisSloppy"))
11900 .ToLocalChecked());
11901 Local<Function> ReturnThisStrict = Local<Function>::Cast(
11902 context->Global()
11903 ->Get(context.local(), v8_str("ReturnThisStrict"))
11904 .ToLocalChecked());
11905
11906 Local<v8::Value> a1 =
11907 ReturnThisSloppy->CallAsFunction(context.local(),
11908 v8::Undefined(isolate), 0, NULL__null)
11909 .ToLocalChecked();
11910 CHECK(a1->StrictEquals(context->Global()))do { if ((__builtin_expect(!!(!(a1->StrictEquals(context->
Global()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11910
, "Check failed: %s.", "a1->StrictEquals(context->Global())"
); } } while (0)
;
11911 Local<v8::Value> a2 =
11912 ReturnThisSloppy->CallAsFunction(context.local(), v8::Null(isolate), 0,
11913 NULL__null)
11914 .ToLocalChecked();
11915 CHECK(a2->StrictEquals(context->Global()))do { if ((__builtin_expect(!!(!(a2->StrictEquals(context->
Global()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11915
, "Check failed: %s.", "a2->StrictEquals(context->Global())"
); } } while (0)
;
11916 Local<v8::Value> a3 =
11917 ReturnThisSloppy->CallAsFunction(context.local(), v8_num(42), 0, NULL__null)
11918 .ToLocalChecked();
11919 CHECK(a3->IsNumberObject())do { if ((__builtin_expect(!!(!(a3->IsNumberObject())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11919, "Check failed: %s."
, "a3->IsNumberObject()"); } } while (0)
;
11920 CHECK_EQ(42.0, a3.As<v8::NumberObject>()->ValueOf())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(a3.As<v8::NumberObject>()->ValueOf()), "42.0" " " "=="
" " "a3.As<v8::NumberObject>()->ValueOf()")) { V8_Fatal
("../test/cctest/test-api.cc", 11920, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
11921 Local<v8::Value> a4 =
11922 ReturnThisSloppy->CallAsFunction(context.local(), v8_str("hello"), 0,
11923 NULL__null)
11924 .ToLocalChecked();
11925 CHECK(a4->IsStringObject())do { if ((__builtin_expect(!!(!(a4->IsStringObject())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 11925, "Check failed: %s."
, "a4->IsStringObject()"); } } while (0)
;
11926 CHECK(a4.As<v8::StringObject>()->ValueOf()->StrictEquals(v8_str("hello")))do { if ((__builtin_expect(!!(!(a4.As<v8::StringObject>
()->ValueOf()->StrictEquals(v8_str("hello")))), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11926, "Check failed: %s.", "a4.As<v8::StringObject>()->ValueOf()->StrictEquals(v8_str(\"hello\"))"
); } } while (0)
;
11927 Local<v8::Value> a5 =
11928 ReturnThisSloppy->CallAsFunction(context.local(), v8::True(isolate), 0,
11929 NULL__null)
11930 .ToLocalChecked();
11931 CHECK(a5->IsBooleanObject())do { if ((__builtin_expect(!!(!(a5->IsBooleanObject())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11931, "Check failed: %s."
, "a5->IsBooleanObject()"); } } while (0)
;
11932 CHECK(a5.As<v8::BooleanObject>()->ValueOf())do { if ((__builtin_expect(!!(!(a5.As<v8::BooleanObject>
()->ValueOf())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 11932, "Check failed: %s.", "a5.As<v8::BooleanObject>()->ValueOf()"
); } } while (0)
;
11933
11934 Local<v8::Value> a6 =
11935 ReturnThisStrict->CallAsFunction(context.local(),
11936 v8::Undefined(isolate), 0, NULL__null)
11937 .ToLocalChecked();
11938 CHECK(a6->IsUndefined())do { if ((__builtin_expect(!!(!(a6->IsUndefined())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 11938, "Check failed: %s."
, "a6->IsUndefined()"); } } while (0)
;
11939 Local<v8::Value> a7 =
11940 ReturnThisStrict->CallAsFunction(context.local(), v8::Null(isolate), 0,
11941 NULL__null)
11942 .ToLocalChecked();
11943 CHECK(a7->IsNull())do { if ((__builtin_expect(!!(!(a7->IsNull())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 11943, "Check failed: %s.", "a7->IsNull()"
); } } while (0)
;
11944 Local<v8::Value> a8 =
11945 ReturnThisStrict->CallAsFunction(context.local(), v8_num(42), 0, NULL__null)
11946 .ToLocalChecked();
11947 CHECK(a8->StrictEquals(v8_num(42)))do { if ((__builtin_expect(!!(!(a8->StrictEquals(v8_num(42
)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11947, "Check failed: %s."
, "a8->StrictEquals(v8_num(42))"); } } while (0)
;
11948 Local<v8::Value> a9 =
11949 ReturnThisStrict->CallAsFunction(context.local(), v8_str("hello"), 0,
11950 NULL__null)
11951 .ToLocalChecked();
11952 CHECK(a9->StrictEquals(v8_str("hello")))do { if ((__builtin_expect(!!(!(a9->StrictEquals(v8_str("hello"
)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11952, "Check failed: %s."
, "a9->StrictEquals(v8_str(\"hello\"))"); } } while (0)
;
11953 Local<v8::Value> a10 =
11954 ReturnThisStrict->CallAsFunction(context.local(), v8::True(isolate), 0,
11955 NULL__null)
11956 .ToLocalChecked();
11957 CHECK(a10->StrictEquals(v8::True(isolate)))do { if ((__builtin_expect(!!(!(a10->StrictEquals(v8::True
(isolate)))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 11957
, "Check failed: %s.", "a10->StrictEquals(v8::True(isolate))"
); } } while (0)
;
11958 }
11959}
11960
11961
11962// Check whether a non-function object is callable.
11963THREADED_TEST(CallableObject)static void TestCallableObject(); RegisterThreadedTest register_CallableObject
(TestCallableObject, "CallableObject"); static void TestCallableObject
(); CcTest register_test_CallableObject(TestCallableObject, "../test/cctest/test-api.cc"
, "CallableObject", __null, true, true); static void TestCallableObject
()
{
11964 LocalContext context;
11965 v8::Isolate* isolate = context->GetIsolate();
11966 v8::HandleScope scope(isolate);
11967
11968 {
11969 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
11970 instance_template->SetCallAsFunctionHandler(call_as_function);
11971 Local<Object> instance =
11972 instance_template->NewInstance(context.local()).ToLocalChecked();
11973 v8::TryCatch try_catch(isolate);
11974
11975 CHECK(instance->IsCallable())do { if ((__builtin_expect(!!(!(instance->IsCallable())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11975, "Check failed: %s."
, "instance->IsCallable()"); } } while (0)
;
11976 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11976, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11977 }
11978
11979 {
11980 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
11981 Local<Object> instance =
11982 instance_template->NewInstance(context.local()).ToLocalChecked();
11983 v8::TryCatch try_catch(isolate);
11984
11985 CHECK(!instance->IsCallable())do { if ((__builtin_expect(!!(!(!instance->IsCallable())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 11985, "Check failed: %s."
, "!instance->IsCallable()"); } } while (0)
;
11986 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11986, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11987 }
11988
11989 {
11990 Local<FunctionTemplate> function_template =
11991 FunctionTemplate::New(isolate, call_as_function);
11992 Local<Function> function =
11993 function_template->GetFunction(context.local()).ToLocalChecked();
11994 Local<Object> instance = function;
11995 v8::TryCatch try_catch(isolate);
11996
11997 CHECK(instance->IsCallable())do { if ((__builtin_expect(!!(!(instance->IsCallable())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 11997, "Check failed: %s."
, "instance->IsCallable()"); } } while (0)
;
11998 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 11998, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
11999 }
12000
12001 {
12002 Local<FunctionTemplate> function_template = FunctionTemplate::New(isolate);
12003 Local<Function> function =
12004 function_template->GetFunction(context.local()).ToLocalChecked();
12005 Local<Object> instance = function;
12006 v8::TryCatch try_catch(isolate);
12007
12008 CHECK(instance->IsCallable())do { if ((__builtin_expect(!!(!(instance->IsCallable())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 12008, "Check failed: %s."
, "instance->IsCallable()"); } } while (0)
;
12009 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 12009, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
12010 }
12011}
12012
12013
12014THREADED_TEST(Regress567998)static void TestRegress567998(); RegisterThreadedTest register_Regress567998
(TestRegress567998, "Regress567998"); static void TestRegress567998
(); CcTest register_test_Regress567998(TestRegress567998, "../test/cctest/test-api.cc"
, "Regress567998", __null, true, true); static void TestRegress567998
()
{
12015 LocalContext env;
12016 v8::HandleScope scope(env->GetIsolate());
12017
12018 Local<v8::FunctionTemplate> desc =
12019 v8::FunctionTemplate::New(env->GetIsolate());
12020 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
12021 desc->InstanceTemplate()->SetCallAsFunctionHandler(ReturnThis); // callable
12022
12023 Local<v8::Object> obj = desc->GetFunction(env.local())
12024 .ToLocalChecked()
12025 ->NewInstance(env.local())
12026 .ToLocalChecked();
12027 CHECK(do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("undetectable"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12028, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"undetectable\"), obj).FromJust()"
); } } while (0)
12028 env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("undetectable"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12028, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"undetectable\"), obj).FromJust()"
); } } while (0)
;
12029
12030 ExpectString("undetectable.toString()", "[object Object]");
12031 ExpectString("typeof undetectable", "undefined");
12032 ExpectString("typeof(undetectable)", "undefined");
12033 ExpectBoolean("typeof undetectable == 'undefined'", true);
12034 ExpectBoolean("typeof undetectable == 'object'", false);
12035 ExpectBoolean("if (undetectable) { true; } else { false; }", false);
12036 ExpectBoolean("!undetectable", true);
12037
12038 ExpectObject("true&&undetectable", obj);
12039 ExpectBoolean("false&&undetectable", false);
12040 ExpectBoolean("true||undetectable", true);
12041 ExpectObject("false||undetectable", obj);
12042
12043 ExpectObject("undetectable&&true", obj);
12044 ExpectObject("undetectable&&false", obj);
12045 ExpectBoolean("undetectable||true", true);
12046 ExpectBoolean("undetectable||false", false);
12047
12048 ExpectBoolean("undetectable==null", true);
12049 ExpectBoolean("null==undetectable", true);
12050 ExpectBoolean("undetectable==undefined", true);
12051 ExpectBoolean("undefined==undetectable", true);
12052 ExpectBoolean("undetectable==undetectable", true);
12053
12054 ExpectBoolean("undetectable===null", false);
12055 ExpectBoolean("null===undetectable", false);
12056 ExpectBoolean("undetectable===undefined", false);
12057 ExpectBoolean("undefined===undetectable", false);
12058 ExpectBoolean("undetectable===undetectable", true);
12059}
12060
12061
12062static int Recurse(v8::Isolate* isolate, int depth, int iterations) {
12063 v8::HandleScope scope(isolate);
12064 if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate);
12065 for (int i = 0; i < iterations; i++) {
12066 Local<v8::Number> n(v8::Integer::New(isolate, 42));
12067 }
12068 return Recurse(isolate, depth - 1, iterations);
12069}
12070
12071
12072THREADED_TEST(HandleIteration)static void TestHandleIteration(); RegisterThreadedTest register_HandleIteration
(TestHandleIteration, "HandleIteration"); static void TestHandleIteration
(); CcTest register_test_HandleIteration(TestHandleIteration,
"../test/cctest/test-api.cc", "HandleIteration", __null, true
, true); static void TestHandleIteration()
{
12073 static const int kIterations = 500;
12074 static const int kNesting = 200;
12075 LocalContext context;
12076 v8::Isolate* isolate = context->GetIsolate();
12077 v8::HandleScope scope0(isolate);
12078 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (v8
::HandleScope::NumberOfHandles(isolate)), "0" " " "==" " " "v8::HandleScope::NumberOfHandles(isolate)"
)) { V8_Fatal("../test/cctest/test-api.cc", 12078, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12079 {
12080 v8::HandleScope scope1(isolate);
12081 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (v8
::HandleScope::NumberOfHandles(isolate)), "0" " " "==" " " "v8::HandleScope::NumberOfHandles(isolate)"
)) { V8_Fatal("../test/cctest/test-api.cc", 12081, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12082 for (int i = 0; i < kIterations; i++) {
12083 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42));
12084 CHECK_EQ(i + 1, v8::HandleScope::NumberOfHandles(isolate))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (i + 1)
, (v8::HandleScope::NumberOfHandles(isolate)), "i + 1" " " "=="
" " "v8::HandleScope::NumberOfHandles(isolate)")) { V8_Fatal
("../test/cctest/test-api.cc", 12084, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
12085 }
12086
12087 CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kIterations
), (v8::HandleScope::NumberOfHandles(isolate)), "kIterations"
" " "==" " " "v8::HandleScope::NumberOfHandles(isolate)")) {
V8_Fatal("../test/cctest/test-api.cc", 12087, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12088 {
12089 v8::HandleScope scope2(CcTest::isolate());
12090 for (int j = 0; j < kIterations; j++) {
12091 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42));
12092 CHECK_EQ(j + 1 + kIterations,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (j + 1 +
kIterations), (v8::HandleScope::NumberOfHandles(isolate)), "j + 1 + kIterations"
" " "==" " " "v8::HandleScope::NumberOfHandles(isolate)")) {
V8_Fatal("../test/cctest/test-api.cc", 12093, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12093 v8::HandleScope::NumberOfHandles(isolate))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (j + 1 +
kIterations), (v8::HandleScope::NumberOfHandles(isolate)), "j + 1 + kIterations"
" " "==" " " "v8::HandleScope::NumberOfHandles(isolate)")) {
V8_Fatal("../test/cctest/test-api.cc", 12093, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12094 }
12095 }
12096 CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kIterations
), (v8::HandleScope::NumberOfHandles(isolate)), "kIterations"
" " "==" " " "v8::HandleScope::NumberOfHandles(isolate)")) {
V8_Fatal("../test/cctest/test-api.cc", 12096, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12097 }
12098 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (v8
::HandleScope::NumberOfHandles(isolate)), "0" " " "==" " " "v8::HandleScope::NumberOfHandles(isolate)"
)) { V8_Fatal("../test/cctest/test-api.cc", 12098, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12099 CHECK_EQ(kNesting * kIterations, Recurse(isolate, kNesting, kIterations))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kNesting
* kIterations), (Recurse(isolate, kNesting, kIterations)), "kNesting * kIterations"
" " "==" " " "Recurse(isolate, kNesting, kIterations)")) { V8_Fatal
("../test/cctest/test-api.cc", 12099, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
12100}
12101
12102
12103static void InterceptorCallICFastApi(
12104 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
12105 ApiTestFuzzer::Fuzz();
12106 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(InterceptorCallICFastApi)))
);
12107 int* call_count =
12108 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value());
12109 ++(*call_count);
12110 if ((*call_count) % 20 == 0) {
12111 CcTest::heap()->CollectAllGarbage();
12112 }
12113}
12114
12115static void FastApiCallback_TrivialSignature(
12116 const v8::FunctionCallbackInfo<v8::Value>& args) {
12117 ApiTestFuzzer::Fuzz();
12118 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(FastApiCallback_TrivialSignature)))
);
12119 v8::Isolate* isolate = CcTest::isolate();
12120 CHECK_EQ(isolate, args.GetIsolate())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (isolate
), (args.GetIsolate()), "isolate" " " "==" " " "args.GetIsolate()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12120, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12121 CHECK(args.This()do { if ((__builtin_expect(!!(!(args.This() ->Equals(isolate
->GetCurrentContext(), args.Holder()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 12123, "Check failed: %s."
, "args.This() ->Equals(isolate->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
12122 ->Equals(isolate->GetCurrentContext(), args.Holder())do { if ((__builtin_expect(!!(!(args.This() ->Equals(isolate
->GetCurrentContext(), args.Holder()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 12123, "Check failed: %s."
, "args.This() ->Equals(isolate->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
12123 .FromJust())do { if ((__builtin_expect(!!(!(args.This() ->Equals(isolate
->GetCurrentContext(), args.Holder()) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 12123, "Check failed: %s."
, "args.This() ->Equals(isolate->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
;
12124 CHECK(args.Data()do { if ((__builtin_expect(!!(!(args.Data() ->Equals(isolate
->GetCurrentContext(), v8_str("method_data")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12126, "Check failed: %s."
, "args.Data() ->Equals(isolate->GetCurrentContext(), v8_str(\"method_data\")) .FromJust()"
); } } while (0)
12125 ->Equals(isolate->GetCurrentContext(), v8_str("method_data"))do { if ((__builtin_expect(!!(!(args.Data() ->Equals(isolate
->GetCurrentContext(), v8_str("method_data")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12126, "Check failed: %s."
, "args.Data() ->Equals(isolate->GetCurrentContext(), v8_str(\"method_data\")) .FromJust()"
); } } while (0)
12126 .FromJust())do { if ((__builtin_expect(!!(!(args.Data() ->Equals(isolate
->GetCurrentContext(), v8_str("method_data")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12126, "Check failed: %s."
, "args.Data() ->Equals(isolate->GetCurrentContext(), v8_str(\"method_data\")) .FromJust()"
); } } while (0)
;
12127 args.GetReturnValue().Set(
12128 args[0]->Int32Value(isolate->GetCurrentContext()).FromJust() + 1);
12129}
12130
12131static void FastApiCallback_SimpleSignature(
12132 const v8::FunctionCallbackInfo<v8::Value>& args) {
12133 ApiTestFuzzer::Fuzz();
12134 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_SimpleSignature)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(FastApiCallback_SimpleSignature)))
);
12135 v8::Isolate* isolate = CcTest::isolate();
12136 CHECK_EQ(isolate, args.GetIsolate())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (isolate
), (args.GetIsolate()), "isolate" " " "==" " " "args.GetIsolate()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12136, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12137 CHECK(args.This()do { if ((__builtin_expect(!!(!(args.This() ->GetPrototype
() ->Equals(isolate->GetCurrentContext(), args.Holder()
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12140, "Check failed: %s.", "args.This() ->GetPrototype() ->Equals(isolate->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
12138 ->GetPrototype()do { if ((__builtin_expect(!!(!(args.This() ->GetPrototype
() ->Equals(isolate->GetCurrentContext(), args.Holder()
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12140, "Check failed: %s.", "args.This() ->GetPrototype() ->Equals(isolate->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
12139 ->Equals(isolate->GetCurrentContext(), args.Holder())do { if ((__builtin_expect(!!(!(args.This() ->GetPrototype
() ->Equals(isolate->GetCurrentContext(), args.Holder()
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12140, "Check failed: %s.", "args.This() ->GetPrototype() ->Equals(isolate->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
12140 .FromJust())do { if ((__builtin_expect(!!(!(args.This() ->GetPrototype
() ->Equals(isolate->GetCurrentContext(), args.Holder()
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12140, "Check failed: %s.", "args.This() ->GetPrototype() ->Equals(isolate->GetCurrentContext(), args.Holder()) .FromJust()"
); } } while (0)
;
12141 CHECK(args.Data()do { if ((__builtin_expect(!!(!(args.Data() ->Equals(isolate
->GetCurrentContext(), v8_str("method_data")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12143, "Check failed: %s."
, "args.Data() ->Equals(isolate->GetCurrentContext(), v8_str(\"method_data\")) .FromJust()"
); } } while (0)
12142 ->Equals(isolate->GetCurrentContext(), v8_str("method_data"))do { if ((__builtin_expect(!!(!(args.Data() ->Equals(isolate
->GetCurrentContext(), v8_str("method_data")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12143, "Check failed: %s."
, "args.Data() ->Equals(isolate->GetCurrentContext(), v8_str(\"method_data\")) .FromJust()"
); } } while (0)
12143 .FromJust())do { if ((__builtin_expect(!!(!(args.Data() ->Equals(isolate
->GetCurrentContext(), v8_str("method_data")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12143, "Check failed: %s."
, "args.Data() ->Equals(isolate->GetCurrentContext(), v8_str(\"method_data\")) .FromJust()"
); } } while (0)
;
12144 // Note, we're using HasRealNamedProperty instead of Has to avoid
12145 // invoking the interceptor again.
12146 CHECK(args.Holder()do { if ((__builtin_expect(!!(!(args.Holder() ->HasRealNamedProperty
(isolate->GetCurrentContext(), v8_str("foo")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12148, "Check failed: %s."
, "args.Holder() ->HasRealNamedProperty(isolate->GetCurrentContext(), v8_str(\"foo\")) .FromJust()"
); } } while (0)
12147 ->HasRealNamedProperty(isolate->GetCurrentContext(), v8_str("foo"))do { if ((__builtin_expect(!!(!(args.Holder() ->HasRealNamedProperty
(isolate->GetCurrentContext(), v8_str("foo")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12148, "Check failed: %s."
, "args.Holder() ->HasRealNamedProperty(isolate->GetCurrentContext(), v8_str(\"foo\")) .FromJust()"
); } } while (0)
12148 .FromJust())do { if ((__builtin_expect(!!(!(args.Holder() ->HasRealNamedProperty
(isolate->GetCurrentContext(), v8_str("foo")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12148, "Check failed: %s."
, "args.Holder() ->HasRealNamedProperty(isolate->GetCurrentContext(), v8_str(\"foo\")) .FromJust()"
); } } while (0)
;
12149 args.GetReturnValue().Set(
12150 args[0]->Int32Value(isolate->GetCurrentContext()).FromJust() + 1);
12151}
12152
12153
12154// Helper to maximize the odds of object moving.
12155static void GenerateSomeGarbage() {
12156 CompileRun(
12157 "var garbage;"
12158 "for (var i = 0; i < 1000; i++) {"
12159 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];"
12160 "}"
12161 "garbage = undefined;");
12162}
12163
12164
12165void DirectApiCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
12166 static int count = 0;
12167 if (count++ % 3 == 0) {
12168 CcTest::heap()->CollectAllGarbage();
12169 // This should move the stub
12170 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed
12171 }
12172}
12173
12174
12175THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub)static void TestCallICFastApi_DirectCall_GCMoveStub(); RegisterThreadedTest
register_CallICFastApi_DirectCall_GCMoveStub(TestCallICFastApi_DirectCall_GCMoveStub
, "CallICFastApi_DirectCall_GCMoveStub"); static void TestCallICFastApi_DirectCall_GCMoveStub
(); CcTest register_test_CallICFastApi_DirectCall_GCMoveStub(
TestCallICFastApi_DirectCall_GCMoveStub, "../test/cctest/test-api.cc"
, "CallICFastApi_DirectCall_GCMoveStub", __null, true, true);
static void TestCallICFastApi_DirectCall_GCMoveStub()
{
12176 LocalContext context;
12177 v8::Isolate* isolate = context->GetIsolate();
12178 v8::HandleScope scope(isolate);
12179 v8::Local<v8::ObjectTemplate> nativeobject_templ =
12180 v8::ObjectTemplate::New(isolate);
12181 nativeobject_templ->Set(isolate, "callback",
12182 v8::FunctionTemplate::New(isolate,
12183 DirectApiCallback));
12184 v8::Local<v8::Object> nativeobject_obj =
12185 nativeobject_templ->NewInstance(context.local()).ToLocalChecked();
12186 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("nativeobject"), nativeobject_obj) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12188
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"nativeobject\"), nativeobject_obj) .FromJust()"
); } } while (0)
12187 ->Set(context.local(), v8_str("nativeobject"), nativeobject_obj)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("nativeobject"), nativeobject_obj) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12188
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"nativeobject\"), nativeobject_obj) .FromJust()"
); } } while (0)
12188 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("nativeobject"), nativeobject_obj) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12188
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"nativeobject\"), nativeobject_obj) .FromJust()"
); } } while (0)
;
12189 // call the api function multiple times to ensure direct call stub creation.
12190 CompileRun(
12191 "function f() {"
12192 " for (var i = 1; i <= 30; i++) {"
12193 " nativeobject.callback();"
12194 " }"
12195 "}"
12196 "f();");
12197}
12198
12199
12200void ThrowingDirectApiCallback(
12201 const v8::FunctionCallbackInfo<v8::Value>& args) {
12202 args.GetIsolate()->ThrowException(v8_str("g"));
12203}
12204
12205
12206THREADED_TEST(CallICFastApi_DirectCall_Throw)static void TestCallICFastApi_DirectCall_Throw(); RegisterThreadedTest
register_CallICFastApi_DirectCall_Throw(TestCallICFastApi_DirectCall_Throw
, "CallICFastApi_DirectCall_Throw"); static void TestCallICFastApi_DirectCall_Throw
(); CcTest register_test_CallICFastApi_DirectCall_Throw(TestCallICFastApi_DirectCall_Throw
, "../test/cctest/test-api.cc", "CallICFastApi_DirectCall_Throw"
, __null, true, true); static void TestCallICFastApi_DirectCall_Throw
()
{
12207 LocalContext context;
12208 v8::Isolate* isolate = context->GetIsolate();
12209 v8::HandleScope scope(isolate);
12210 v8::Local<v8::ObjectTemplate> nativeobject_templ =
12211 v8::ObjectTemplate::New(isolate);
12212 nativeobject_templ->Set(isolate, "callback",
12213 v8::FunctionTemplate::New(isolate,
12214 ThrowingDirectApiCallback));
12215 v8::Local<v8::Object> nativeobject_obj =
12216 nativeobject_templ->NewInstance(context.local()).ToLocalChecked();
12217 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("nativeobject"), nativeobject_obj) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12219
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"nativeobject\"), nativeobject_obj) .FromJust()"
); } } while (0)
12218 ->Set(context.local(), v8_str("nativeobject"), nativeobject_obj)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("nativeobject"), nativeobject_obj) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12219
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"nativeobject\"), nativeobject_obj) .FromJust()"
); } } while (0)
12219 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("nativeobject"), nativeobject_obj) .
FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12219
, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"nativeobject\"), nativeobject_obj) .FromJust()"
); } } while (0)
;
12220 // call the api function multiple times to ensure direct call stub creation.
12221 v8::Local<Value> result = CompileRun(
12222 "var result = '';"
12223 "function f() {"
12224 " for (var i = 1; i <= 5; i++) {"
12225 " try { nativeobject.callback(); } catch (e) { result += e; }"
12226 " }"
12227 "}"
12228 "f(); result;");
12229 CHECK(v8_str("ggggg")->Equals(context.local(), result).FromJust())do { if ((__builtin_expect(!!(!(v8_str("ggggg")->Equals(context
.local(), result).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12229, "Check failed: %s.", "v8_str(\"ggggg\")->Equals(context.local(), result).FromJust()"
); } } while (0)
;
12230}
12231
12232
12233static int p_getter_count_3;
12234
12235
12236static Local<Value> DoDirectGetter() {
12237 if (++p_getter_count_3 % 3 == 0) {
12238 CcTest::heap()->CollectAllGarbage();
12239 GenerateSomeGarbage();
12240 }
12241 return v8_str("Direct Getter Result");
12242}
12243
12244
12245static void DirectGetterCallback(
12246 Local<String> name,
12247 const v8::PropertyCallbackInfo<v8::Value>& info) {
12248 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterCallback)(reinterpret_cast<v8::internal::Address>(reinterpret_cast
<intptr_t>(DirectGetterCallback)))
);
12249 info.GetReturnValue().Set(DoDirectGetter());
12250}
12251
12252
12253template<typename Accessor>
12254static void LoadICFastApi_DirectCall_GCMoveStub(Accessor accessor) {
12255 LocalContext context;
12256 v8::Isolate* isolate = context->GetIsolate();
12257 v8::HandleScope scope(isolate);
12258 v8::Local<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate);
12259 obj->SetAccessor(v8_str("p1"), accessor);
12260 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12263, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12261 ->Set(context.local(), v8_str("o1"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12263, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12262 obj->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12263, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12263 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12263, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12264 p_getter_count_3 = 0;
12265 v8::Local<v8::Value> result = CompileRun(
12266 "function f() {"
12267 " for (var i = 0; i < 30; i++) o1.p1;"
12268 " return o1.p1"
12269 "}"
12270 "f();");
12271 CHECK(v8_str("Direct Getter Result")do { if ((__builtin_expect(!!(!(v8_str("Direct Getter Result"
) ->Equals(context.local(), result) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12273, "Check failed: %s.", "v8_str(\"Direct Getter Result\") ->Equals(context.local(), result) .FromJust()"
); } } while (0)
12272 ->Equals(context.local(), result)do { if ((__builtin_expect(!!(!(v8_str("Direct Getter Result"
) ->Equals(context.local(), result) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12273, "Check failed: %s.", "v8_str(\"Direct Getter Result\") ->Equals(context.local(), result) .FromJust()"
); } } while (0)
12273 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("Direct Getter Result"
) ->Equals(context.local(), result) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12273, "Check failed: %s.", "v8_str(\"Direct Getter Result\") ->Equals(context.local(), result) .FromJust()"
); } } while (0)
;
12274 CHECK_EQ(31, p_getter_count_3)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (31), (
p_getter_count_3), "31" " " "==" " " "p_getter_count_3")) { V8_Fatal
("../test/cctest/test-api.cc", 12274, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
12275}
12276
12277
12278THREADED_PROFILED_TEST(LoadICFastApi_DirectCall_GCMoveStub)static void TestLoadICFastApi_DirectCall_GCMoveStub(); static
void TestLoadICFastApi_DirectCall_GCMoveStubWithProfiler(); CcTest
register_test_LoadICFastApi_DirectCall_GCMoveStubWithProfiler
(TestLoadICFastApi_DirectCall_GCMoveStubWithProfiler, "../test/cctest/test-api.cc"
, "LoadICFastApi_DirectCall_GCMoveStubWithProfiler", __null, true
, true); static void TestLoadICFastApi_DirectCall_GCMoveStubWithProfiler
() { RunWithProfiler(&TestLoadICFastApi_DirectCall_GCMoveStub
); } static void TestLoadICFastApi_DirectCall_GCMoveStub(); RegisterThreadedTest
register_LoadICFastApi_DirectCall_GCMoveStub(TestLoadICFastApi_DirectCall_GCMoveStub
, "LoadICFastApi_DirectCall_GCMoveStub"); static void TestLoadICFastApi_DirectCall_GCMoveStub
(); CcTest register_test_LoadICFastApi_DirectCall_GCMoveStub(
TestLoadICFastApi_DirectCall_GCMoveStub, "../test/cctest/test-api.cc"
, "LoadICFastApi_DirectCall_GCMoveStub", __null, true, true);
static void TestLoadICFastApi_DirectCall_GCMoveStub()
{
12279 LoadICFastApi_DirectCall_GCMoveStub(DirectGetterCallback);
12280}
12281
12282
12283void ThrowingDirectGetterCallback(
12284 Local<String> name,
12285 const v8::PropertyCallbackInfo<v8::Value>& info) {
12286 info.GetIsolate()->ThrowException(v8_str("g"));
12287}
12288
12289
12290THREADED_TEST(LoadICFastApi_DirectCall_Throw)static void TestLoadICFastApi_DirectCall_Throw(); RegisterThreadedTest
register_LoadICFastApi_DirectCall_Throw(TestLoadICFastApi_DirectCall_Throw
, "LoadICFastApi_DirectCall_Throw"); static void TestLoadICFastApi_DirectCall_Throw
(); CcTest register_test_LoadICFastApi_DirectCall_Throw(TestLoadICFastApi_DirectCall_Throw
, "../test/cctest/test-api.cc", "LoadICFastApi_DirectCall_Throw"
, __null, true, true); static void TestLoadICFastApi_DirectCall_Throw
()
{
12291 LocalContext context;
12292 v8::Isolate* isolate = context->GetIsolate();
12293 v8::HandleScope scope(isolate);
12294 v8::Local<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(isolate);
12295 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback);
12296 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12299, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12297 ->Set(context.local(), v8_str("o1"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12299, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12298 obj->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12299, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12299 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o1"), obj->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12299, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o1\"), obj->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12300 v8::Local<Value> result = CompileRun(
12301 "var result = '';"
12302 "for (var i = 0; i < 5; i++) {"
12303 " try { o1.p1; } catch (e) { result += e; }"
12304 "}"
12305 "result;");
12306 CHECK(v8_str("ggggg")->Equals(context.local(), result).FromJust())do { if ((__builtin_expect(!!(!(v8_str("ggggg")->Equals(context
.local(), result).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12306, "Check failed: %s.", "v8_str(\"ggggg\")->Equals(context.local(), result).FromJust()"
); } } while (0)
;
12307}
12308
12309
12310THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature)static void TestInterceptorCallICFastApi_TrivialSignature(); static
void TestInterceptorCallICFastApi_TrivialSignatureWithProfiler
(); CcTest register_test_InterceptorCallICFastApi_TrivialSignatureWithProfiler
(TestInterceptorCallICFastApi_TrivialSignatureWithProfiler, "../test/cctest/test-api.cc"
, "InterceptorCallICFastApi_TrivialSignatureWithProfiler", __null
, true, true); static void TestInterceptorCallICFastApi_TrivialSignatureWithProfiler
() { RunWithProfiler(&TestInterceptorCallICFastApi_TrivialSignature
); } static void TestInterceptorCallICFastApi_TrivialSignature
(); RegisterThreadedTest register_InterceptorCallICFastApi_TrivialSignature
(TestInterceptorCallICFastApi_TrivialSignature, "InterceptorCallICFastApi_TrivialSignature"
); static void TestInterceptorCallICFastApi_TrivialSignature(
); CcTest register_test_InterceptorCallICFastApi_TrivialSignature
(TestInterceptorCallICFastApi_TrivialSignature, "../test/cctest/test-api.cc"
, "InterceptorCallICFastApi_TrivialSignature", __null, true, true
); static void TestInterceptorCallICFastApi_TrivialSignature(
)
{
12311 int interceptor_call_count = 0;
12312 v8::Isolate* isolate = CcTest::isolate();
12313 v8::HandleScope scope(isolate);
12314 v8::Local<v8::FunctionTemplate> fun_templ =
12315 v8::FunctionTemplate::New(isolate);
12316 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12317 isolate, FastApiCallback_TrivialSignature, v8_str("method_data"),
12318 v8::Local<v8::Signature>());
12319 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12320 proto_templ->Set(v8_str("method"), method_templ);
12321 v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
12322 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
12323 InterceptorCallICFastApi, NULL__null, NULL__null, NULL__null, NULL__null,
12324 v8::External::New(isolate, &interceptor_call_count)));
12325 LocalContext context;
12326 v8::Local<v8::Function> fun =
12327 fun_templ->GetFunction(context.local()).ToLocalChecked();
12328 GenerateSomeGarbage();
12329 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12332, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12330 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12332, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12331 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12332, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12332 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12332, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12333 CompileRun(
12334 "var result = 0;"
12335 "for (var i = 0; i < 100; i++) {"
12336 " result = o.method(41);"
12337 "}");
12338 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12342, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12339 ->Get(context.local(), v8_str("result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12342, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12340 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12342, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12341 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12342, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12342 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12342, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12343 CHECK_EQ(100, interceptor_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (100), (
interceptor_call_count), "100" " " "==" " " "interceptor_call_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 12343, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12344}
12345
12346
12347THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature)static void TestInterceptorCallICFastApi_SimpleSignature(); static
void TestInterceptorCallICFastApi_SimpleSignatureWithProfiler
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignatureWithProfiler
(TestInterceptorCallICFastApi_SimpleSignatureWithProfiler, "../test/cctest/test-api.cc"
, "InterceptorCallICFastApi_SimpleSignatureWithProfiler", __null
, true, true); static void TestInterceptorCallICFastApi_SimpleSignatureWithProfiler
() { RunWithProfiler(&TestInterceptorCallICFastApi_SimpleSignature
); } static void TestInterceptorCallICFastApi_SimpleSignature
(); RegisterThreadedTest register_InterceptorCallICFastApi_SimpleSignature
(TestInterceptorCallICFastApi_SimpleSignature, "InterceptorCallICFastApi_SimpleSignature"
); static void TestInterceptorCallICFastApi_SimpleSignature()
; CcTest register_test_InterceptorCallICFastApi_SimpleSignature
(TestInterceptorCallICFastApi_SimpleSignature, "../test/cctest/test-api.cc"
, "InterceptorCallICFastApi_SimpleSignature", __null, true, true
); static void TestInterceptorCallICFastApi_SimpleSignature()
{
12348 int interceptor_call_count = 0;
12349 v8::Isolate* isolate = CcTest::isolate();
12350 v8::HandleScope scope(isolate);
12351 v8::Local<v8::FunctionTemplate> fun_templ =
12352 v8::FunctionTemplate::New(isolate);
12353 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12354 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12355 v8::Signature::New(isolate, fun_templ));
12356 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12357 proto_templ->Set(v8_str("method"), method_templ);
12358 fun_templ->SetHiddenPrototype(true);
12359 v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
12360 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
12361 InterceptorCallICFastApi, NULL__null, NULL__null, NULL__null, NULL__null,
12362 v8::External::New(isolate, &interceptor_call_count)));
12363 LocalContext context;
12364 v8::Local<v8::Function> fun =
12365 fun_templ->GetFunction(context.local()).ToLocalChecked();
12366 GenerateSomeGarbage();
12367 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12370, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12368 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12370, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12369 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12370, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12370 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12370, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12371 CompileRun(
12372 "o.foo = 17;"
12373 "var receiver = {};"
12374 "receiver.__proto__ = o;"
12375 "var result = 0;"
12376 "for (var i = 0; i < 100; i++) {"
12377 " result = receiver.method(41);"
12378 "}");
12379 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12383, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12380 ->Get(context.local(), v8_str("result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12383, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12381 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12383, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12382 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12383, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12383 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12383, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12384 CHECK_EQ(100, interceptor_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (100), (
interceptor_call_count), "100" " " "==" " " "interceptor_call_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 12384, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12385}
12386
12387
12388THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1)static void TestInterceptorCallICFastApi_SimpleSignature_Miss1
(); static void TestInterceptorCallICFastApi_SimpleSignature_Miss1WithProfiler
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignature_Miss1WithProfiler
(TestInterceptorCallICFastApi_SimpleSignature_Miss1WithProfiler
, "../test/cctest/test-api.cc", "InterceptorCallICFastApi_SimpleSignature_Miss1WithProfiler"
, __null, true, true); static void TestInterceptorCallICFastApi_SimpleSignature_Miss1WithProfiler
() { RunWithProfiler(&TestInterceptorCallICFastApi_SimpleSignature_Miss1
); } static void TestInterceptorCallICFastApi_SimpleSignature_Miss1
(); RegisterThreadedTest register_InterceptorCallICFastApi_SimpleSignature_Miss1
(TestInterceptorCallICFastApi_SimpleSignature_Miss1, "InterceptorCallICFastApi_SimpleSignature_Miss1"
); static void TestInterceptorCallICFastApi_SimpleSignature_Miss1
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignature_Miss1
(TestInterceptorCallICFastApi_SimpleSignature_Miss1, "../test/cctest/test-api.cc"
, "InterceptorCallICFastApi_SimpleSignature_Miss1", __null, true
, true); static void TestInterceptorCallICFastApi_SimpleSignature_Miss1
()
{
12389 int interceptor_call_count = 0;
12390 v8::Isolate* isolate = CcTest::isolate();
12391 v8::HandleScope scope(isolate);
12392 v8::Local<v8::FunctionTemplate> fun_templ =
12393 v8::FunctionTemplate::New(isolate);
12394 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12395 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12396 v8::Signature::New(isolate, fun_templ));
12397 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12398 proto_templ->Set(v8_str("method"), method_templ);
12399 fun_templ->SetHiddenPrototype(true);
12400 v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
12401 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
12402 InterceptorCallICFastApi, NULL__null, NULL__null, NULL__null, NULL__null,
12403 v8::External::New(isolate, &interceptor_call_count)));
12404 LocalContext context;
12405 v8::Local<v8::Function> fun =
12406 fun_templ->GetFunction(context.local()).ToLocalChecked();
12407 GenerateSomeGarbage();
12408 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12411, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12409 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12411, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12410 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12411, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12411 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12411, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12412 CompileRun(
12413 "o.foo = 17;"
12414 "var receiver = {};"
12415 "receiver.__proto__ = o;"
12416 "var result = 0;"
12417 "var saved_result = 0;"
12418 "for (var i = 0; i < 100; i++) {"
12419 " result = receiver.method(41);"
12420 " if (i == 50) {"
12421 " saved_result = result;"
12422 " receiver = {method: function(x) { return x - 1 }};"
12423 " }"
12424 "}");
12425 CHECK_EQ(40, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12429, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12426 ->Get(context.local(), v8_str("result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12429, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12427 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12429, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12428 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12429, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12429 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12429, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12430 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12434, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12431 ->Get(context.local(), v8_str("saved_result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12434, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12432 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12434, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12433 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12434, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12434 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12434, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12435 CHECK_GE(interceptor_call_count, 50)do { if (std::string* _msg = ::v8::base::CheckGEImpl( (interceptor_call_count
), (50), "interceptor_call_count" " " ">=" " " "50")) { V8_Fatal
("../test/cctest/test-api.cc", 12435, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
12436}
12437
12438
12439THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2)static void TestInterceptorCallICFastApi_SimpleSignature_Miss2
(); static void TestInterceptorCallICFastApi_SimpleSignature_Miss2WithProfiler
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignature_Miss2WithProfiler
(TestInterceptorCallICFastApi_SimpleSignature_Miss2WithProfiler
, "../test/cctest/test-api.cc", "InterceptorCallICFastApi_SimpleSignature_Miss2WithProfiler"
, __null, true, true); static void TestInterceptorCallICFastApi_SimpleSignature_Miss2WithProfiler
() { RunWithProfiler(&TestInterceptorCallICFastApi_SimpleSignature_Miss2
); } static void TestInterceptorCallICFastApi_SimpleSignature_Miss2
(); RegisterThreadedTest register_InterceptorCallICFastApi_SimpleSignature_Miss2
(TestInterceptorCallICFastApi_SimpleSignature_Miss2, "InterceptorCallICFastApi_SimpleSignature_Miss2"
); static void TestInterceptorCallICFastApi_SimpleSignature_Miss2
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignature_Miss2
(TestInterceptorCallICFastApi_SimpleSignature_Miss2, "../test/cctest/test-api.cc"
, "InterceptorCallICFastApi_SimpleSignature_Miss2", __null, true
, true); static void TestInterceptorCallICFastApi_SimpleSignature_Miss2
()
{
12440 int interceptor_call_count = 0;
12441 v8::Isolate* isolate = CcTest::isolate();
12442 v8::HandleScope scope(isolate);
12443 v8::Local<v8::FunctionTemplate> fun_templ =
12444 v8::FunctionTemplate::New(isolate);
12445 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12446 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12447 v8::Signature::New(isolate, fun_templ));
12448 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12449 proto_templ->Set(v8_str("method"), method_templ);
12450 fun_templ->SetHiddenPrototype(true);
12451 v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
12452 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
12453 InterceptorCallICFastApi, NULL__null, NULL__null, NULL__null, NULL__null,
12454 v8::External::New(isolate, &interceptor_call_count)));
12455 LocalContext context;
12456 v8::Local<v8::Function> fun =
12457 fun_templ->GetFunction(context.local()).ToLocalChecked();
12458 GenerateSomeGarbage();
12459 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12462, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12460 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12462, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12461 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12462, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12462 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12462, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12463 CompileRun(
12464 "o.foo = 17;"
12465 "var receiver = {};"
12466 "receiver.__proto__ = o;"
12467 "var result = 0;"
12468 "var saved_result = 0;"
12469 "for (var i = 0; i < 100; i++) {"
12470 " result = receiver.method(41);"
12471 " if (i == 50) {"
12472 " saved_result = result;"
12473 " o.method = function(x) { return x - 1 };"
12474 " }"
12475 "}");
12476 CHECK_EQ(40, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12480, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12477 ->Get(context.local(), v8_str("result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12480, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12478 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12480, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12479 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12480, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12480 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12480, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12481 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12482 ->Get(context.local(), v8_str("saved_result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12483 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12484 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12485 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12485, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12486 CHECK_GE(interceptor_call_count, 50)do { if (std::string* _msg = ::v8::base::CheckGEImpl( (interceptor_call_count
), (50), "interceptor_call_count" " " ">=" " " "50")) { V8_Fatal
("../test/cctest/test-api.cc", 12486, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
12487}
12488
12489
12490THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3)static void TestInterceptorCallICFastApi_SimpleSignature_Miss3
(); static void TestInterceptorCallICFastApi_SimpleSignature_Miss3WithProfiler
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignature_Miss3WithProfiler
(TestInterceptorCallICFastApi_SimpleSignature_Miss3WithProfiler
, "../test/cctest/test-api.cc", "InterceptorCallICFastApi_SimpleSignature_Miss3WithProfiler"
, __null, true, true); static void TestInterceptorCallICFastApi_SimpleSignature_Miss3WithProfiler
() { RunWithProfiler(&TestInterceptorCallICFastApi_SimpleSignature_Miss3
); } static void TestInterceptorCallICFastApi_SimpleSignature_Miss3
(); RegisterThreadedTest register_InterceptorCallICFastApi_SimpleSignature_Miss3
(TestInterceptorCallICFastApi_SimpleSignature_Miss3, "InterceptorCallICFastApi_SimpleSignature_Miss3"
); static void TestInterceptorCallICFastApi_SimpleSignature_Miss3
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignature_Miss3
(TestInterceptorCallICFastApi_SimpleSignature_Miss3, "../test/cctest/test-api.cc"
, "InterceptorCallICFastApi_SimpleSignature_Miss3", __null, true
, true); static void TestInterceptorCallICFastApi_SimpleSignature_Miss3
()
{
12491 int interceptor_call_count = 0;
12492 v8::Isolate* isolate = CcTest::isolate();
12493 v8::HandleScope scope(isolate);
12494 v8::Local<v8::FunctionTemplate> fun_templ =
12495 v8::FunctionTemplate::New(isolate);
12496 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12497 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12498 v8::Signature::New(isolate, fun_templ));
12499 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12500 proto_templ->Set(v8_str("method"), method_templ);
12501 fun_templ->SetHiddenPrototype(true);
12502 v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
12503 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
12504 InterceptorCallICFastApi, NULL__null, NULL__null, NULL__null, NULL__null,
12505 v8::External::New(isolate, &interceptor_call_count)));
12506 LocalContext context;
12507 v8::Local<v8::Function> fun =
12508 fun_templ->GetFunction(context.local()).ToLocalChecked();
12509 GenerateSomeGarbage();
12510 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12513, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12511 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12513, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12512 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12513, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12513 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12513, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12514 v8::TryCatch try_catch(isolate);
12515 CompileRun(
12516 "o.foo = 17;"
12517 "var receiver = {};"
12518 "receiver.__proto__ = o;"
12519 "var result = 0;"
12520 "var saved_result = 0;"
12521 "for (var i = 0; i < 100; i++) {"
12522 " result = receiver.method(41);"
12523 " if (i == 50) {"
12524 " saved_result = result;"
12525 " receiver = 333;"
12526 " }"
12527 "}");
12528 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12528, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12529 // TODO(verwaest): Adjust message.
12530 CHECK(do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12535, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12531 v8_str("TypeError: receiver.method is not a function")do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12535, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12532 ->Equals(do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12535, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12533 context.local(),do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12535, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12534 try_catch.Exception()->ToString(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12535, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12535 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12535, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12536 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12540, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12537 ->Get(context.local(), v8_str("saved_result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12540, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12538 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12540, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12539 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12540, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12540 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12540, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12541 CHECK_GE(interceptor_call_count, 50)do { if (std::string* _msg = ::v8::base::CheckGEImpl( (interceptor_call_count
), (50), "interceptor_call_count" " " ">=" " " "50")) { V8_Fatal
("../test/cctest/test-api.cc", 12541, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
12542}
12543
12544
12545THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError)static void TestInterceptorCallICFastApi_SimpleSignature_TypeError
(); static void TestInterceptorCallICFastApi_SimpleSignature_TypeErrorWithProfiler
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignature_TypeErrorWithProfiler
(TestInterceptorCallICFastApi_SimpleSignature_TypeErrorWithProfiler
, "../test/cctest/test-api.cc", "InterceptorCallICFastApi_SimpleSignature_TypeErrorWithProfiler"
, __null, true, true); static void TestInterceptorCallICFastApi_SimpleSignature_TypeErrorWithProfiler
() { RunWithProfiler(&TestInterceptorCallICFastApi_SimpleSignature_TypeError
); } static void TestInterceptorCallICFastApi_SimpleSignature_TypeError
(); RegisterThreadedTest register_InterceptorCallICFastApi_SimpleSignature_TypeError
(TestInterceptorCallICFastApi_SimpleSignature_TypeError, "InterceptorCallICFastApi_SimpleSignature_TypeError"
); static void TestInterceptorCallICFastApi_SimpleSignature_TypeError
(); CcTest register_test_InterceptorCallICFastApi_SimpleSignature_TypeError
(TestInterceptorCallICFastApi_SimpleSignature_TypeError, "../test/cctest/test-api.cc"
, "InterceptorCallICFastApi_SimpleSignature_TypeError", __null
, true, true); static void TestInterceptorCallICFastApi_SimpleSignature_TypeError
()
{
12546 int interceptor_call_count = 0;
12547 v8::Isolate* isolate = CcTest::isolate();
12548 v8::HandleScope scope(isolate);
12549 v8::Local<v8::FunctionTemplate> fun_templ =
12550 v8::FunctionTemplate::New(isolate);
12551 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12552 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12553 v8::Signature::New(isolate, fun_templ));
12554 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12555 proto_templ->Set(v8_str("method"), method_templ);
12556 fun_templ->SetHiddenPrototype(true);
12557 v8::Local<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
12558 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
12559 InterceptorCallICFastApi, NULL__null, NULL__null, NULL__null, NULL__null,
12560 v8::External::New(isolate, &interceptor_call_count)));
12561 LocalContext context;
12562 v8::Local<v8::Function> fun =
12563 fun_templ->GetFunction(context.local()).ToLocalChecked();
12564 GenerateSomeGarbage();
12565 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12568, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12566 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12568, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12567 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12568, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12568 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12568, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12569 v8::TryCatch try_catch(isolate);
12570 CompileRun(
12571 "o.foo = 17;"
12572 "var receiver = {};"
12573 "receiver.__proto__ = o;"
12574 "var result = 0;"
12575 "var saved_result = 0;"
12576 "for (var i = 0; i < 100; i++) {"
12577 " result = receiver.method(41);"
12578 " if (i == 50) {"
12579 " saved_result = result;"
12580 " receiver = {method: receiver.method};"
12581 " }"
12582 "}");
12583 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12583, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12584 CHECK(do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12589, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12585 v8_str("TypeError: Illegal invocation")do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12589, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12586 ->Equals(do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12589, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12587 context.local(),do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12589, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12588 try_catch.Exception()->ToString(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12589, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12589 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12589, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12590 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12594, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12591 ->Get(context.local(), v8_str("saved_result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12594, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12592 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12594, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12593 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12594, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12594 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12594, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12595 CHECK_GE(interceptor_call_count, 50)do { if (std::string* _msg = ::v8::base::CheckGEImpl( (interceptor_call_count
), (50), "interceptor_call_count" " " ">=" " " "50")) { V8_Fatal
("../test/cctest/test-api.cc", 12595, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
12596}
12597
12598
12599THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature)static void TestCallICFastApi_TrivialSignature(); static void
TestCallICFastApi_TrivialSignatureWithProfiler(); CcTest register_test_CallICFastApi_TrivialSignatureWithProfiler
(TestCallICFastApi_TrivialSignatureWithProfiler, "../test/cctest/test-api.cc"
, "CallICFastApi_TrivialSignatureWithProfiler", __null, true,
true); static void TestCallICFastApi_TrivialSignatureWithProfiler
() { RunWithProfiler(&TestCallICFastApi_TrivialSignature)
; } static void TestCallICFastApi_TrivialSignature(); RegisterThreadedTest
register_CallICFastApi_TrivialSignature(TestCallICFastApi_TrivialSignature
, "CallICFastApi_TrivialSignature"); static void TestCallICFastApi_TrivialSignature
(); CcTest register_test_CallICFastApi_TrivialSignature(TestCallICFastApi_TrivialSignature
, "../test/cctest/test-api.cc", "CallICFastApi_TrivialSignature"
, __null, true, true); static void TestCallICFastApi_TrivialSignature
()
{
12600 v8::Isolate* isolate = CcTest::isolate();
12601 v8::HandleScope scope(isolate);
12602 v8::Local<v8::FunctionTemplate> fun_templ =
12603 v8::FunctionTemplate::New(isolate);
12604 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12605 isolate, FastApiCallback_TrivialSignature, v8_str("method_data"),
12606 v8::Local<v8::Signature>());
12607 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12608 proto_templ->Set(v8_str("method"), method_templ);
12609 v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
12610 USE(templ);
12611 LocalContext context;
12612 v8::Local<v8::Function> fun =
12613 fun_templ->GetFunction(context.local()).ToLocalChecked();
12614 GenerateSomeGarbage();
12615 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12618, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12616 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12618, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12617 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12618, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12618 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12618, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12619 CompileRun(
12620 "var result = 0;"
12621 "for (var i = 0; i < 100; i++) {"
12622 " result = o.method(41);"
12623 "}");
12624
12625 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12629, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12626 ->Get(context.local(), v8_str("result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12629, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12627 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12629, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12628 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12629, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12629 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12629, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12630}
12631
12632
12633THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature)static void TestCallICFastApi_SimpleSignature(); static void TestCallICFastApi_SimpleSignatureWithProfiler
(); CcTest register_test_CallICFastApi_SimpleSignatureWithProfiler
(TestCallICFastApi_SimpleSignatureWithProfiler, "../test/cctest/test-api.cc"
, "CallICFastApi_SimpleSignatureWithProfiler", __null, true, true
); static void TestCallICFastApi_SimpleSignatureWithProfiler(
) { RunWithProfiler(&TestCallICFastApi_SimpleSignature); }
static void TestCallICFastApi_SimpleSignature(); RegisterThreadedTest
register_CallICFastApi_SimpleSignature(TestCallICFastApi_SimpleSignature
, "CallICFastApi_SimpleSignature"); static void TestCallICFastApi_SimpleSignature
(); CcTest register_test_CallICFastApi_SimpleSignature(TestCallICFastApi_SimpleSignature
, "../test/cctest/test-api.cc", "CallICFastApi_SimpleSignature"
, __null, true, true); static void TestCallICFastApi_SimpleSignature
()
{
12634 v8::Isolate* isolate = CcTest::isolate();
12635 v8::HandleScope scope(isolate);
12636 v8::Local<v8::FunctionTemplate> fun_templ =
12637 v8::FunctionTemplate::New(isolate);
12638 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12639 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12640 v8::Signature::New(isolate, fun_templ));
12641 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12642 proto_templ->Set(v8_str("method"), method_templ);
12643 fun_templ->SetHiddenPrototype(true);
12644 v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
12645 CHECK(!templ.IsEmpty())do { if ((__builtin_expect(!!(!(!templ.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12645, "Check failed: %s.", "!templ.IsEmpty()"
); } } while (0)
;
12646 LocalContext context;
12647 v8::Local<v8::Function> fun =
12648 fun_templ->GetFunction(context.local()).ToLocalChecked();
12649 GenerateSomeGarbage();
12650 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12653, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12651 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12653, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12652 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12653, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12653 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12653, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12654 CompileRun(
12655 "o.foo = 17;"
12656 "var receiver = {};"
12657 "receiver.__proto__ = o;"
12658 "var result = 0;"
12659 "for (var i = 0; i < 100; i++) {"
12660 " result = receiver.method(41);"
12661 "}");
12662
12663 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12667, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12664 ->Get(context.local(), v8_str("result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12667, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12665 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12667, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12666 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12667, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12667 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12667, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12668}
12669
12670
12671THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1)static void TestCallICFastApi_SimpleSignature_Miss1(); static
void TestCallICFastApi_SimpleSignature_Miss1WithProfiler(); CcTest
register_test_CallICFastApi_SimpleSignature_Miss1WithProfiler
(TestCallICFastApi_SimpleSignature_Miss1WithProfiler, "../test/cctest/test-api.cc"
, "CallICFastApi_SimpleSignature_Miss1WithProfiler", __null, true
, true); static void TestCallICFastApi_SimpleSignature_Miss1WithProfiler
() { RunWithProfiler(&TestCallICFastApi_SimpleSignature_Miss1
); } static void TestCallICFastApi_SimpleSignature_Miss1(); RegisterThreadedTest
register_CallICFastApi_SimpleSignature_Miss1(TestCallICFastApi_SimpleSignature_Miss1
, "CallICFastApi_SimpleSignature_Miss1"); static void TestCallICFastApi_SimpleSignature_Miss1
(); CcTest register_test_CallICFastApi_SimpleSignature_Miss1(
TestCallICFastApi_SimpleSignature_Miss1, "../test/cctest/test-api.cc"
, "CallICFastApi_SimpleSignature_Miss1", __null, true, true);
static void TestCallICFastApi_SimpleSignature_Miss1()
{
12672 v8::Isolate* isolate = CcTest::isolate();
12673 v8::HandleScope scope(isolate);
12674 v8::Local<v8::FunctionTemplate> fun_templ =
12675 v8::FunctionTemplate::New(isolate);
12676 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12677 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12678 v8::Signature::New(isolate, fun_templ));
12679 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12680 proto_templ->Set(v8_str("method"), method_templ);
12681 fun_templ->SetHiddenPrototype(true);
12682 v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
12683 CHECK(!templ.IsEmpty())do { if ((__builtin_expect(!!(!(!templ.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12683, "Check failed: %s.", "!templ.IsEmpty()"
); } } while (0)
;
12684 LocalContext context;
12685 v8::Local<v8::Function> fun =
12686 fun_templ->GetFunction(context.local()).ToLocalChecked();
12687 GenerateSomeGarbage();
12688 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12691, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12689 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12691, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12690 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12691, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12691 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12691, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12692 CompileRun(
12693 "o.foo = 17;"
12694 "var receiver = {};"
12695 "receiver.__proto__ = o;"
12696 "var result = 0;"
12697 "var saved_result = 0;"
12698 "for (var i = 0; i < 100; i++) {"
12699 " result = receiver.method(41);"
12700 " if (i == 50) {"
12701 " saved_result = result;"
12702 " receiver = {method: function(x) { return x - 1 }};"
12703 " }"
12704 "}");
12705 CHECK_EQ(40, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12709, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12706 ->Get(context.local(), v8_str("result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12709, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12707 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12709, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12708 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12709, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12709 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (40), (
context->Global() ->Get(context.local(), v8_str("result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "40" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12709, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12710 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12714, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12711 ->Get(context.local(), v8_str("saved_result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12714, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12712 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12714, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12713 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12714, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12714 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12714, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12715}
12716
12717
12718THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2)static void TestCallICFastApi_SimpleSignature_Miss2(); static
void TestCallICFastApi_SimpleSignature_Miss2WithProfiler(); CcTest
register_test_CallICFastApi_SimpleSignature_Miss2WithProfiler
(TestCallICFastApi_SimpleSignature_Miss2WithProfiler, "../test/cctest/test-api.cc"
, "CallICFastApi_SimpleSignature_Miss2WithProfiler", __null, true
, true); static void TestCallICFastApi_SimpleSignature_Miss2WithProfiler
() { RunWithProfiler(&TestCallICFastApi_SimpleSignature_Miss2
); } static void TestCallICFastApi_SimpleSignature_Miss2(); RegisterThreadedTest
register_CallICFastApi_SimpleSignature_Miss2(TestCallICFastApi_SimpleSignature_Miss2
, "CallICFastApi_SimpleSignature_Miss2"); static void TestCallICFastApi_SimpleSignature_Miss2
(); CcTest register_test_CallICFastApi_SimpleSignature_Miss2(
TestCallICFastApi_SimpleSignature_Miss2, "../test/cctest/test-api.cc"
, "CallICFastApi_SimpleSignature_Miss2", __null, true, true);
static void TestCallICFastApi_SimpleSignature_Miss2()
{
12719 v8::Isolate* isolate = CcTest::isolate();
12720 v8::HandleScope scope(isolate);
12721 v8::Local<v8::FunctionTemplate> fun_templ =
12722 v8::FunctionTemplate::New(isolate);
12723 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12724 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12725 v8::Signature::New(isolate, fun_templ));
12726 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12727 proto_templ->Set(v8_str("method"), method_templ);
12728 fun_templ->SetHiddenPrototype(true);
12729 v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
12730 CHECK(!templ.IsEmpty())do { if ((__builtin_expect(!!(!(!templ.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12730, "Check failed: %s.", "!templ.IsEmpty()"
); } } while (0)
;
12731 LocalContext context;
12732 v8::Local<v8::Function> fun =
12733 fun_templ->GetFunction(context.local()).ToLocalChecked();
12734 GenerateSomeGarbage();
12735 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12738, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12736 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12738, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12737 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12738, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12738 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12738, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12739 v8::TryCatch try_catch(isolate);
12740 CompileRun(
12741 "o.foo = 17;"
12742 "var receiver = {};"
12743 "receiver.__proto__ = o;"
12744 "var result = 0;"
12745 "var saved_result = 0;"
12746 "for (var i = 0; i < 100; i++) {"
12747 " result = receiver.method(41);"
12748 " if (i == 50) {"
12749 " saved_result = result;"
12750 " receiver = 333;"
12751 " }"
12752 "}");
12753 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12753, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12754 // TODO(verwaest): Adjust message.
12755 CHECK(do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12760, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12756 v8_str("TypeError: receiver.method is not a function")do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12760, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12757 ->Equals(do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12760, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12758 context.local(),do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12760, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12759 try_catch.Exception()->ToString(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12760, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12760 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("TypeError: receiver.method is not a function"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12760, "Check failed: %s.", "v8_str(\"TypeError: receiver.method is not a function\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12761 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12765, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12762 ->Get(context.local(), v8_str("saved_result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12765, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12763 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12765, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12764 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12765, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12765 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12765, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12766}
12767
12768
12769THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError)static void TestCallICFastApi_SimpleSignature_TypeError(); static
void TestCallICFastApi_SimpleSignature_TypeErrorWithProfiler
(); CcTest register_test_CallICFastApi_SimpleSignature_TypeErrorWithProfiler
(TestCallICFastApi_SimpleSignature_TypeErrorWithProfiler, "../test/cctest/test-api.cc"
, "CallICFastApi_SimpleSignature_TypeErrorWithProfiler", __null
, true, true); static void TestCallICFastApi_SimpleSignature_TypeErrorWithProfiler
() { RunWithProfiler(&TestCallICFastApi_SimpleSignature_TypeError
); } static void TestCallICFastApi_SimpleSignature_TypeError(
); RegisterThreadedTest register_CallICFastApi_SimpleSignature_TypeError
(TestCallICFastApi_SimpleSignature_TypeError, "CallICFastApi_SimpleSignature_TypeError"
); static void TestCallICFastApi_SimpleSignature_TypeError();
CcTest register_test_CallICFastApi_SimpleSignature_TypeError
(TestCallICFastApi_SimpleSignature_TypeError, "../test/cctest/test-api.cc"
, "CallICFastApi_SimpleSignature_TypeError", __null, true, true
); static void TestCallICFastApi_SimpleSignature_TypeError()
{
12770 v8::Isolate* isolate = CcTest::isolate();
12771 v8::HandleScope scope(isolate);
12772 v8::Local<v8::FunctionTemplate> fun_templ =
12773 v8::FunctionTemplate::New(isolate);
12774 v8::Local<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12775 isolate, FastApiCallback_SimpleSignature, v8_str("method_data"),
12776 v8::Signature::New(isolate, fun_templ));
12777 v8::Local<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12778 proto_templ->Set(v8_str("method"), method_templ);
12779 fun_templ->SetHiddenPrototype(true);
12780 v8::Local<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
12781 CHECK(!templ.IsEmpty())do { if ((__builtin_expect(!!(!(!templ.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12781, "Check failed: %s.", "!templ.IsEmpty()"
); } } while (0)
;
12782 LocalContext context;
12783 v8::Local<v8::Function> fun =
12784 fun_templ->GetFunction(context.local()).ToLocalChecked();
12785 GenerateSomeGarbage();
12786 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12789, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12787 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12789, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12788 fun->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12789, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12789 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), fun->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12789, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), fun->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12790 v8::TryCatch try_catch(isolate);
12791 CompileRun(
12792 "o.foo = 17;"
12793 "var receiver = {};"
12794 "receiver.__proto__ = o;"
12795 "var result = 0;"
12796 "var saved_result = 0;"
12797 "for (var i = 0; i < 100; i++) {"
12798 " result = receiver.method(41);"
12799 " if (i == 50) {"
12800 " saved_result = result;"
12801 " receiver = Object.create(receiver);"
12802 " }"
12803 "}");
12804 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12804, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12805 CHECK(do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12810, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12806 v8_str("TypeError: Illegal invocation")do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12810, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12807 ->Equals(do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12810, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12808 context.local(),do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12810, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12809 try_catch.Exception()->ToString(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12810, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
12810 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("TypeError: Illegal invocation"
) ->Equals( context.local(), try_catch.Exception()->ToString
(context.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12810, "Check failed: %s.", "v8_str(\"TypeError: Illegal invocation\") ->Equals( context.local(), try_catch.Exception()->ToString(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
12811 CHECK_EQ(42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12815, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12812 ->Get(context.local(), v8_str("saved_result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12815, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12813 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12815, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12814 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12815, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
12815 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
context->Global() ->Get(context.local(), v8_str("saved_result"
)) .ToLocalChecked() ->Int32Value(context.local()) .FromJust
()), "42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"saved_result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 12815, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
12816}
12817
12818
12819static void ThrowingGetter(Local<String> name,
12820 const v8::PropertyCallbackInfo<v8::Value>& info) {
12821 ApiTestFuzzer::Fuzz();
12822 info.GetIsolate()->ThrowException(Local<Value>());
12823 info.GetReturnValue().SetUndefined();
12824}
12825
12826
12827THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks)static void TestVariousGetPropertiesAndThrowingCallbacks(); RegisterThreadedTest
register_VariousGetPropertiesAndThrowingCallbacks(TestVariousGetPropertiesAndThrowingCallbacks
, "VariousGetPropertiesAndThrowingCallbacks"); static void TestVariousGetPropertiesAndThrowingCallbacks
(); CcTest register_test_VariousGetPropertiesAndThrowingCallbacks
(TestVariousGetPropertiesAndThrowingCallbacks, "../test/cctest/test-api.cc"
, "VariousGetPropertiesAndThrowingCallbacks", __null, true, true
); static void TestVariousGetPropertiesAndThrowingCallbacks()
{
12828 LocalContext context;
12829 HandleScope scope(context->GetIsolate());
12830
12831 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
12832 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate();
12833 instance_templ->SetAccessor(v8_str("f"), ThrowingGetter);
12834
12835 Local<Object> instance = templ->GetFunction(context.local())
12836 .ToLocalChecked()
12837 ->NewInstance(context.local())
12838 .ToLocalChecked();
12839
12840 Local<Object> another = Object::New(context->GetIsolate());
12841 CHECK(another->SetPrototype(context.local(), instance).FromJust())do { if ((__builtin_expect(!!(!(another->SetPrototype(context
.local(), instance).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 12841, "Check failed: %s.", "another->SetPrototype(context.local(), instance).FromJust()"
); } } while (0)
;
12842
12843 Local<Object> with_js_getter = CompileRun(
12844 "o = {};\n"
12845 "o.__defineGetter__('f', function() { throw undefined; });\n"
12846 "o\n").As<Object>();
12847 CHECK(!with_js_getter.IsEmpty())do { if ((__builtin_expect(!!(!(!with_js_getter.IsEmpty())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 12847, "Check failed: %s."
, "!with_js_getter.IsEmpty()"); } } while (0)
;
12848
12849 TryCatch try_catch(context->GetIsolate());
12850
12851 v8::MaybeLocal<Value> result =
12852 instance->GetRealNamedProperty(context.local(), v8_str("f"));
12853 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12853, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12854 try_catch.Reset();
12855 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12855, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
12856
12857 Maybe<PropertyAttribute> attr =
12858 instance->GetRealNamedPropertyAttributes(context.local(), v8_str("f"));
12859 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 12859, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
12860 CHECK(Just(None) == attr)do { if ((__builtin_expect(!!(!(Just(None) == attr)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12860, "Check failed: %s.", "Just(None) == attr"
); } } while (0)
;
12861
12862 result = another->GetRealNamedProperty(context.local(), v8_str("f"));
12863 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12863, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12864 try_catch.Reset();
12865 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12865, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
12866
12867 attr = another->GetRealNamedPropertyAttributes(context.local(), v8_str("f"));
12868 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 12868, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
12869 CHECK(Just(None) == attr)do { if ((__builtin_expect(!!(!(Just(None) == attr)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12869, "Check failed: %s.", "Just(None) == attr"
); } } while (0)
;
12870
12871 result = another->GetRealNamedPropertyInPrototypeChain(context.local(),
12872 v8_str("f"));
12873 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12873, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12874 try_catch.Reset();
12875 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12875, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
12876
12877 attr = another->GetRealNamedPropertyAttributesInPrototypeChain(
12878 context.local(), v8_str("f"));
12879 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 12879, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
12880 CHECK(Just(None) == attr)do { if ((__builtin_expect(!!(!(Just(None) == attr)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12880, "Check failed: %s.", "Just(None) == attr"
); } } while (0)
;
12881
12882 result = another->Get(context.local(), v8_str("f"));
12883 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12883, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12884 try_catch.Reset();
12885 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12885, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
12886
12887 result = with_js_getter->GetRealNamedProperty(context.local(), v8_str("f"));
12888 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12888, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12889 try_catch.Reset();
12890 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12890, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
12891
12892 attr = with_js_getter->GetRealNamedPropertyAttributes(context.local(),
12893 v8_str("f"));
12894 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 12894, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
12895 CHECK(Just(None) == attr)do { if ((__builtin_expect(!!(!(Just(None) == attr)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12895, "Check failed: %s.", "Just(None) == attr"
); } } while (0)
;
12896
12897 result = with_js_getter->Get(context.local(), v8_str("f"));
12898 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12898, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12899 try_catch.Reset();
12900 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12900, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
12901
12902 Local<Object> target = CompileRun("({})").As<Object>();
12903 Local<Object> handler = CompileRun("({})").As<Object>();
12904 Local<v8::Proxy> proxy =
12905 v8::Proxy::New(context.local(), target, handler).ToLocalChecked();
12906
12907 result = target->GetRealNamedProperty(context.local(), v8_str("f"));
12908 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 12908, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
12909 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12909, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
12910
12911 result = proxy->GetRealNamedProperty(context.local(), v8_str("f"));
12912 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 12912, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
12913 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12913, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
12914}
12915
12916
12917static void ThrowingCallbackWithTryCatch(
12918 const v8::FunctionCallbackInfo<v8::Value>& args) {
12919 TryCatch try_catch(args.GetIsolate());
12920 // Verboseness is important: it triggers message delivery which can call into
12921 // external code.
12922 try_catch.SetVerbose(true);
12923 CompileRun("throw 'from JS';");
12924 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 12924, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
12925 CHECK(!CcTest::i_isolate()->has_pending_exception())do { if ((__builtin_expect(!!(!(!CcTest::i_isolate()->has_pending_exception
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12925, "Check failed: %s."
, "!CcTest::i_isolate()->has_pending_exception()"); } } while
(0)
;
12926 CHECK(!CcTest::i_isolate()->has_scheduled_exception())do { if ((__builtin_expect(!!(!(!CcTest::i_isolate()->has_scheduled_exception
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12926, "Check failed: %s."
, "!CcTest::i_isolate()->has_scheduled_exception()"); } } while
(0)
;
12927}
12928
12929
12930static int call_depth;
12931
12932
12933static void WithTryCatch(Local<Message> message, Local<Value> data) {
12934 TryCatch try_catch(CcTest::isolate());
12935}
12936
12937
12938static void ThrowFromJS(Local<Message> message, Local<Value> data) {
12939 if (--call_depth) CompileRun("throw 'ThrowInJS';");
12940}
12941
12942
12943static void ThrowViaApi(Local<Message> message, Local<Value> data) {
12944 if (--call_depth) CcTest::isolate()->ThrowException(v8_str("ThrowViaApi"));
12945}
12946
12947
12948static void WebKitLike(Local<Message> message, Local<Value> data) {
12949 Local<String> errorMessageString = message->Get();
12950 CHECK(!errorMessageString.IsEmpty())do { if ((__builtin_expect(!!(!(!errorMessageString.IsEmpty()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 12950, "Check failed: %s."
, "!errorMessageString.IsEmpty()"); } } while (0)
;
12951 message->GetStackTrace();
12952 message->GetScriptOrigin().ResourceName();
12953}
12954
12955
12956THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch)static void TestExceptionsDoNotPropagatePastTryCatch(); RegisterThreadedTest
register_ExceptionsDoNotPropagatePastTryCatch(TestExceptionsDoNotPropagatePastTryCatch
, "ExceptionsDoNotPropagatePastTryCatch"); static void TestExceptionsDoNotPropagatePastTryCatch
(); CcTest register_test_ExceptionsDoNotPropagatePastTryCatch
(TestExceptionsDoNotPropagatePastTryCatch, "../test/cctest/test-api.cc"
, "ExceptionsDoNotPropagatePastTryCatch", __null, true, true)
; static void TestExceptionsDoNotPropagatePastTryCatch()
{
12957 LocalContext context;
12958 v8::Isolate* isolate = context->GetIsolate();
12959 HandleScope scope(isolate);
12960
12961 Local<Function> func =
12962 FunctionTemplate::New(isolate, ThrowingCallbackWithTryCatch)
12963 ->GetFunction(context.local())
12964 .ToLocalChecked();
12965 CHECK(do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("func"), func).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12966, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"func\"), func).FromJust()"
); } } while (0)
12966 context->Global()->Set(context.local(), v8_str("func"), func).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("func"), func).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 12966, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"func\"), func).FromJust()"
); } } while (0)
;
12967
12968 MessageCallback callbacks[] =
12969 { NULL__null, WebKitLike, ThrowViaApi, ThrowFromJS, WithTryCatch };
12970 for (unsigned i = 0; i < sizeof(callbacks)/sizeof(callbacks[0]); i++) {
12971 MessageCallback callback = callbacks[i];
12972 if (callback != NULL__null) {
12973 isolate->AddMessageListener(callback);
12974 }
12975 // Some small number to control number of times message handler should
12976 // throw an exception.
12977 call_depth = 5;
12978 ExpectFalse(
12979 "var thrown = false;\n"
12980 "try { func(); } catch(e) { thrown = true; }\n"
12981 "thrown\n");
12982 if (callback != NULL__null) {
12983 isolate->RemoveMessageListeners(callback);
12984 }
12985 }
12986}
12987
12988
12989static void ParentGetter(Local<String> name,
12990 const v8::PropertyCallbackInfo<v8::Value>& info) {
12991 ApiTestFuzzer::Fuzz();
12992 info.GetReturnValue().Set(v8_num(1));
12993}
12994
12995
12996static void ChildGetter(Local<String> name,
12997 const v8::PropertyCallbackInfo<v8::Value>& info) {
12998 ApiTestFuzzer::Fuzz();
12999 info.GetReturnValue().Set(v8_num(42));
13000}
13001
13002
13003THREADED_TEST(Overriding)static void TestOverriding(); RegisterThreadedTest register_Overriding
(TestOverriding, "Overriding"); static void TestOverriding();
CcTest register_test_Overriding(TestOverriding, "../test/cctest/test-api.cc"
, "Overriding", __null, true, true); static void TestOverriding
()
{
13004 LocalContext context;
13005 v8::Isolate* isolate = context->GetIsolate();
13006 v8::HandleScope scope(isolate);
13007
13008 // Parent template.
13009 Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New(isolate);
13010 Local<ObjectTemplate> parent_instance_templ =
13011 parent_templ->InstanceTemplate();
13012 parent_instance_templ->SetAccessor(v8_str("f"), ParentGetter);
13013
13014 // Template that inherits from the parent template.
13015 Local<v8::FunctionTemplate> child_templ = v8::FunctionTemplate::New(isolate);
13016 Local<ObjectTemplate> child_instance_templ =
13017 child_templ->InstanceTemplate();
13018 child_templ->Inherit(parent_templ);
13019 // Override 'f'. The child version of 'f' should get called for child
13020 // instances.
13021 child_instance_templ->SetAccessor(v8_str("f"), ChildGetter);
13022 // Add 'g' twice. The 'g' added last should get called for instances.
13023 child_instance_templ->SetAccessor(v8_str("g"), ParentGetter);
13024 child_instance_templ->SetAccessor(v8_str("g"), ChildGetter);
13025
13026 // Add 'h' as an accessor to the proto template with ReadOnly attributes
13027 // so 'h' can be shadowed on the instance object.
13028 Local<ObjectTemplate> child_proto_templ = child_templ->PrototypeTemplate();
13029 child_proto_templ->SetAccessor(v8_str("h"), ParentGetter, 0,
13030 v8::Local<Value>(), v8::DEFAULT, v8::ReadOnly);
13031
13032 // Add 'i' as an accessor to the instance template with ReadOnly attributes
13033 // but the attribute does not have effect because it is duplicated with
13034 // NULL setter.
13035 child_instance_templ->SetAccessor(v8_str("i"), ChildGetter, 0,
13036 v8::Local<Value>(), v8::DEFAULT,
13037 v8::ReadOnly);
13038
13039
13040 // Instantiate the child template.
13041 Local<v8::Object> instance = child_templ->GetFunction(context.local())
13042 .ToLocalChecked()
13043 ->NewInstance(context.local())
13044 .ToLocalChecked();
13045
13046 // Check that the child function overrides the parent one.
13047 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), instance) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13049, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"o\"), instance) .FromJust()"
); } } while (0)
13048 ->Set(context.local(), v8_str("o"), instance)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), instance) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13049, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"o\"), instance) .FromJust()"
); } } while (0)
13049 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), instance) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13049, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"o\"), instance) .FromJust()"
); } } while (0)
;
13050 Local<Value> value = v8_compile("o.f")->Run(context.local()).ToLocalChecked();
13051 // Check that the 'g' that was added last is hit.
13052 CHECK_EQ(42, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 13052, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
13053 value = v8_compile("o.g")->Run(context.local()).ToLocalChecked();
13054 CHECK_EQ(42, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 13054, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
13055
13056 // Check that 'h' cannot be shadowed.
13057 value = v8_compile("o.h = 3; o.h")->Run(context.local()).ToLocalChecked();
13058 CHECK_EQ(1, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (value
->Int32Value(context.local()).FromJust()), "1" " " "==" " "
"value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 13058, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
13059
13060 // Check that 'i' cannot be shadowed or changed.
13061 value = v8_compile("o.i = 3; o.i")->Run(context.local()).ToLocalChecked();
13062 CHECK_EQ(42, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 13062, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
13063}
13064
13065
13066static void ShouldThrowOnErrorGetter(
13067 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
13068 ApiTestFuzzer::Fuzz();
13069 v8::Isolate* isolate = info.GetIsolate();
13070 Local<Boolean> should_throw_on_error =
13071 Boolean::New(isolate, info.ShouldThrowOnError());
13072 info.GetReturnValue().Set(should_throw_on_error);
13073}
13074
13075
13076template <typename T>
13077static void ShouldThrowOnErrorSetter(Local<Name> name, Local<v8::Value> value,
13078 const v8::PropertyCallbackInfo<T>& info) {
13079 ApiTestFuzzer::Fuzz();
13080 v8::Isolate* isolate = info.GetIsolate();
13081 auto context = isolate->GetCurrentContext();
13082 Local<Boolean> should_throw_on_error_value =
13083 Boolean::New(isolate, info.ShouldThrowOnError());
13084 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_setter"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13087, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_setter\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13085 ->Set(isolate->GetCurrentContext(), v8_str("should_throw_setter"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_setter"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13087, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_setter\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13086 should_throw_on_error_value)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_setter"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13087, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_setter\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13087 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_setter"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13087, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_setter\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
;
13088}
13089
13090
13091THREADED_TEST(AccessorShouldThrowOnError)static void TestAccessorShouldThrowOnError(); RegisterThreadedTest
register_AccessorShouldThrowOnError(TestAccessorShouldThrowOnError
, "AccessorShouldThrowOnError"); static void TestAccessorShouldThrowOnError
(); CcTest register_test_AccessorShouldThrowOnError(TestAccessorShouldThrowOnError
, "../test/cctest/test-api.cc", "AccessorShouldThrowOnError",
__null, true, true); static void TestAccessorShouldThrowOnError
()
{
13092 i::FLAG_strong_mode = true;
13093 LocalContext context;
13094 v8::Isolate* isolate = context->GetIsolate();
13095 v8::HandleScope scope(isolate);
13096 Local<Object> global = context->Global();
13097
13098 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
13099 Local<ObjectTemplate> instance_templ = templ->InstanceTemplate();
13100 instance_templ->SetAccessor(v8_str("f"), ShouldThrowOnErrorGetter,
13101 ShouldThrowOnErrorSetter<void>);
13102
13103 Local<v8::Object> instance = templ->GetFunction(context.local())
13104 .ToLocalChecked()
13105 ->NewInstance(context.local())
13106 .ToLocalChecked();
13107
13108 CHECK(global->Set(context.local(), v8_str("o"), instance).FromJust())do { if ((__builtin_expect(!!(!(global->Set(context.local(
), v8_str("o"), instance).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13108, "Check failed: %s.", "global->Set(context.local(), v8_str(\"o\"), instance).FromJust()"
); } } while (0)
;
13109
13110 // SLOPPY mode
13111 Local<Value> value = v8_compile("o.f")->Run(context.local()).ToLocalChecked();
13112 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13112, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13113 v8_compile("o.f = 153")->Run(context.local()).ToLocalChecked();
13114 value = global->Get(context.local(), v8_str("should_throw_setter"))
13115 .ToLocalChecked();
13116 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13116, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13117
13118 // STRICT mode
13119 value = v8_compile("'use strict';o.f")->Run(context.local()).ToLocalChecked();
13120 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13120, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13121 v8_compile("'use strict'; o.f = 153")->Run(context.local()).ToLocalChecked();
13122 value = global->Get(context.local(), v8_str("should_throw_setter"))
13123 .ToLocalChecked();
13124 CHECK(value->IsTrue())do { if ((__builtin_expect(!!(!(value->IsTrue())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13124, "Check failed: %s.", "value->IsTrue()"
); } } while (0)
;
13125
13126 // STRONG mode
13127 value = v8_compile("'use strong';o.f")->Run(context.local()).ToLocalChecked();
13128 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13128, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13129 v8_compile("'use strong'; o.f = 153")->Run(context.local()).ToLocalChecked();
13130 value = global->Get(context.local(), v8_str("should_throw_setter"))
13131 .ToLocalChecked();
13132 CHECK(value->IsTrue())do { if ((__builtin_expect(!!(!(value->IsTrue())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13132, "Check failed: %s.", "value->IsTrue()"
); } } while (0)
;
13133}
13134
13135
13136static void ShouldThrowOnErrorQuery(
13137 Local<Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info) {
13138 ApiTestFuzzer::Fuzz();
13139 v8::Isolate* isolate = info.GetIsolate();
13140 info.GetReturnValue().Set(v8::None);
13141
13142 auto context = isolate->GetCurrentContext();
13143 Local<Boolean> should_throw_on_error_value =
13144 Boolean::New(isolate, info.ShouldThrowOnError());
13145 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_query"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13148, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_query\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13146 ->Set(isolate->GetCurrentContext(), v8_str("should_throw_query"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_query"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13148, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_query\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13147 should_throw_on_error_value)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_query"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13148, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_query\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13148 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_query"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13148, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_query\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
;
13149}
13150
13151
13152static void ShouldThrowOnErrorDeleter(
13153 Local<Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) {
13154 ApiTestFuzzer::Fuzz();
13155 v8::Isolate* isolate = info.GetIsolate();
13156 info.GetReturnValue().Set(v8::True(isolate));
13157
13158 auto context = isolate->GetCurrentContext();
13159 Local<Boolean> should_throw_on_error_value =
13160 Boolean::New(isolate, info.ShouldThrowOnError());
13161 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_deleter"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13164, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_deleter\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13162 ->Set(isolate->GetCurrentContext(), v8_str("should_throw_deleter"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_deleter"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13164, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_deleter\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13163 should_throw_on_error_value)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_deleter"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13164, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_deleter\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13164 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_deleter"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13164, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_deleter\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
;
13165}
13166
13167
13168static void ShouldThrowOnErrorPropertyEnumerator(
13169 const v8::PropertyCallbackInfo<v8::Array>& info) {
13170 ApiTestFuzzer::Fuzz();
13171 v8::Isolate* isolate = info.GetIsolate();
13172 Local<v8::Array> names = v8::Array::New(isolate, 1);
13173 CHECK(names->Set(isolate->GetCurrentContext(), names, v8_num(1)).FromJust())do { if ((__builtin_expect(!!(!(names->Set(isolate->GetCurrentContext
(), names, v8_num(1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13173, "Check failed: %s.", "names->Set(isolate->GetCurrentContext(), names, v8_num(1)).FromJust()"
); } } while (0)
;
13174 info.GetReturnValue().Set(names);
13175
13176 auto context = isolate->GetCurrentContext();
13177 Local<Boolean> should_throw_on_error_value =
13178 Boolean::New(isolate, info.ShouldThrowOnError());
13179 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_enumerator"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13183, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_enumerator\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13180 ->Set(isolate->GetCurrentContext(),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_enumerator"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13183, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_enumerator\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13181 v8_str("should_throw_enumerator"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_enumerator"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13183, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_enumerator\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13182 should_throw_on_error_value)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_enumerator"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13183, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_enumerator\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
13183 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(isolate->GetCurrentContext(), v8_str("should_throw_enumerator"
), should_throw_on_error_value) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13183, "Check failed: %s.", "context->Global() ->Set(isolate->GetCurrentContext(), v8_str(\"should_throw_enumerator\"), should_throw_on_error_value) .FromJust()"
); } } while (0)
;
13184}
13185
13186
13187THREADED_TEST(InterceptorShouldThrowOnError)static void TestInterceptorShouldThrowOnError(); RegisterThreadedTest
register_InterceptorShouldThrowOnError(TestInterceptorShouldThrowOnError
, "InterceptorShouldThrowOnError"); static void TestInterceptorShouldThrowOnError
(); CcTest register_test_InterceptorShouldThrowOnError(TestInterceptorShouldThrowOnError
, "../test/cctest/test-api.cc", "InterceptorShouldThrowOnError"
, __null, true, true); static void TestInterceptorShouldThrowOnError
()
{
13188 i::FLAG_strong_mode = true;
13189 LocalContext context;
13190 v8::Isolate* isolate = context->GetIsolate();
13191 v8::HandleScope scope(isolate);
13192 Local<Object> global = context->Global();
13193
13194 auto interceptor_templ = v8::ObjectTemplate::New(isolate);
13195 v8::NamedPropertyHandlerConfiguration handler(
13196 ShouldThrowOnErrorGetter, ShouldThrowOnErrorSetter<Value>,
13197 ShouldThrowOnErrorQuery, ShouldThrowOnErrorDeleter,
13198 ShouldThrowOnErrorPropertyEnumerator);
13199 interceptor_templ->SetHandler(handler);
13200
13201 Local<v8::Object> instance =
13202 interceptor_templ->NewInstance(context.local()).ToLocalChecked();
13203
13204 CHECK(global->Set(context.local(), v8_str("o"), instance).FromJust())do { if ((__builtin_expect(!!(!(global->Set(context.local(
), v8_str("o"), instance).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13204, "Check failed: %s.", "global->Set(context.local(), v8_str(\"o\"), instance).FromJust()"
); } } while (0)
;
13205
13206 // SLOPPY mode
13207 Local<Value> value = v8_compile("o.f")->Run(context.local()).ToLocalChecked();
13208 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13208, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13209 v8_compile("o.f = 153")->Run(context.local()).ToLocalChecked();
13210 value = global->Get(context.local(), v8_str("should_throw_setter"))
13211 .ToLocalChecked();
13212 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13212, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13213
13214 v8_compile("delete o.f")->Run(context.local()).ToLocalChecked();
13215 value = global->Get(context.local(), v8_str("should_throw_deleter"))
13216 .ToLocalChecked();
13217 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13217, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13218
13219 v8_compile("Object.getOwnPropertyNames(o)")
13220 ->Run(context.local())
13221 .ToLocalChecked();
13222 value = global->Get(context.local(), v8_str("should_throw_enumerator"))
13223 .ToLocalChecked();
13224 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13224, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13225
13226 // STRICT mode
13227 value = v8_compile("'use strict';o.f")->Run(context.local()).ToLocalChecked();
13228 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13228, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13229 v8_compile("'use strict'; o.f = 153")->Run(context.local()).ToLocalChecked();
13230 value = global->Get(context.local(), v8_str("should_throw_setter"))
13231 .ToLocalChecked();
13232 CHECK(value->IsTrue())do { if ((__builtin_expect(!!(!(value->IsTrue())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13232, "Check failed: %s.", "value->IsTrue()"
); } } while (0)
;
13233
13234 v8_compile("'use strict'; delete o.f")->Run(context.local()).ToLocalChecked();
13235 value = global->Get(context.local(), v8_str("should_throw_deleter"))
13236 .ToLocalChecked();
13237 CHECK(value->IsTrue())do { if ((__builtin_expect(!!(!(value->IsTrue())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13237, "Check failed: %s.", "value->IsTrue()"
); } } while (0)
;
13238
13239 v8_compile("'use strict'; Object.getOwnPropertyNames(o)")
13240 ->Run(context.local())
13241 .ToLocalChecked();
13242 value = global->Get(context.local(), v8_str("should_throw_enumerator"))
13243 .ToLocalChecked();
13244 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13244, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13245
13246 // STRONG mode
13247 value = v8_compile("'use strong';o.f")->Run(context.local()).ToLocalChecked();
13248 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13248, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13249 v8_compile("'use strong'; o.f = 153")->Run(context.local()).ToLocalChecked();
13250 value = global->Get(context.local(), v8_str("should_throw_setter"))
13251 .ToLocalChecked();
13252 CHECK(value->IsTrue())do { if ((__builtin_expect(!!(!(value->IsTrue())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13252, "Check failed: %s.", "value->IsTrue()"
); } } while (0)
;
13253
13254 v8_compile("'use strong'; Object.getOwnPropertyNames(o)")
13255 ->Run(context.local())
13256 .ToLocalChecked();
13257 value = global->Get(context.local(), v8_str("should_throw_enumerator"))
13258 .ToLocalChecked();
13259 CHECK(value->IsFalse())do { if ((__builtin_expect(!!(!(value->IsFalse())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 13259, "Check failed: %s."
, "value->IsFalse()"); } } while (0)
;
13260}
13261
13262
13263static void IsConstructHandler(
13264 const v8::FunctionCallbackInfo<v8::Value>& args) {
13265 ApiTestFuzzer::Fuzz();
13266 args.GetReturnValue().Set(args.IsConstructCall());
13267}
13268
13269
13270THREADED_TEST(IsConstructCall)static void TestIsConstructCall(); RegisterThreadedTest register_IsConstructCall
(TestIsConstructCall, "IsConstructCall"); static void TestIsConstructCall
(); CcTest register_test_IsConstructCall(TestIsConstructCall,
"../test/cctest/test-api.cc", "IsConstructCall", __null, true
, true); static void TestIsConstructCall()
{
13271 v8::Isolate* isolate = CcTest::isolate();
13272 v8::HandleScope scope(isolate);
13273
13274 // Function template with call handler.
13275 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
13276 templ->SetCallHandler(IsConstructHandler);
13277
13278 LocalContext context;
13279
13280 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13283, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
13281 ->Set(context.local(), v8_str("f"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13283, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
13282 templ->GetFunction(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13283, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
13283 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13283, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
13284 Local<Value> value = v8_compile("f()")->Run(context.local()).ToLocalChecked();
13285 CHECK(!value->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(!value->BooleanValue(context
.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13285, "Check failed: %s.", "!value->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
13286 value = v8_compile("new f()")->Run(context.local()).ToLocalChecked();
13287 CHECK(value->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(value->BooleanValue(context
.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13287, "Check failed: %s.", "value->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
13288}
13289
13290
13291THREADED_TEST(ObjectProtoToString)static void TestObjectProtoToString(); RegisterThreadedTest register_ObjectProtoToString
(TestObjectProtoToString, "ObjectProtoToString"); static void
TestObjectProtoToString(); CcTest register_test_ObjectProtoToString
(TestObjectProtoToString, "../test/cctest/test-api.cc", "ObjectProtoToString"
, __null, true, true); static void TestObjectProtoToString()
{
13292 v8::Isolate* isolate = CcTest::isolate();
13293 v8::HandleScope scope(isolate);
13294 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
13295 templ->SetClassName(v8_str("MyClass"));
13296
13297 LocalContext context;
13298
13299 Local<String> customized_tostring = v8_str("customized toString");
13300
13301 // Replace Object.prototype.toString
13302 v8_compile(
13303 "Object.prototype.toString = function() {"
13304 " return 'customized toString';"
13305 "}")
13306 ->Run(context.local())
13307 .ToLocalChecked();
13308
13309 // Normal ToString call should call replaced Object.prototype.toString
13310 Local<v8::Object> instance = templ->GetFunction(context.local())
13311 .ToLocalChecked()
13312 ->NewInstance(context.local())
13313 .ToLocalChecked();
13314 Local<String> value = instance->ToString(context.local()).ToLocalChecked();
13315 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), customized_tostring).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13316, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), customized_tostring).FromJust()"
); } } while (0)
13316 value->Equals(context.local(), customized_tostring).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), customized_tostring).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13316, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), customized_tostring).FromJust()"
); } } while (0)
;
13317
13318 // ObjectProtoToString should not call replace toString function.
13319 value = instance->ObjectProtoToString(context.local()).ToLocalChecked();
13320 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object MyClass]")
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
13321, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object MyClass]\")).FromJust()"
); } } while (0)
13321 value->Equals(context.local(), v8_str("[object MyClass]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object MyClass]")
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
13321, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object MyClass]\")).FromJust()"
); } } while (0)
;
13322
13323 // Check global
13324 value =
13325 context->Global()->ObjectProtoToString(context.local()).ToLocalChecked();
13326 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object global]"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13327
, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object global]\")).FromJust()"
); } } while (0)
13327 value->Equals(context.local(), v8_str("[object global]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object global]"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13327
, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object global]\")).FromJust()"
); } } while (0)
;
13328
13329 // Check ordinary object
13330 Local<Value> object =
13331 v8_compile("new Object()")->Run(context.local()).ToLocalChecked();
13332 value = object.As<v8::Object>()
13333 ->ObjectProtoToString(context.local())
13334 .ToLocalChecked();
13335 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Object]"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13336
, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object Object]\")).FromJust()"
); } } while (0)
13336 value->Equals(context.local(), v8_str("[object Object]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Object]"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13336
, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object Object]\")).FromJust()"
); } } while (0)
;
13337}
13338
13339
13340TEST(ObjectProtoToStringES6)static void TestObjectProtoToStringES6(); CcTest register_test_ObjectProtoToStringES6
(TestObjectProtoToStringES6, "../test/cctest/test-api.cc", "ObjectProtoToStringES6"
, __null, true, true); static void TestObjectProtoToStringES6
()
{
13341 // TODO(dslomov, caitp): merge into ObjectProtoToString test once shipped.
13342 i::FLAG_harmony_tostring = true;
13343 LocalContext context;
13344 v8::Isolate* isolate = CcTest::isolate();
13345 v8::HandleScope scope(isolate);
13346 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
13347 templ->SetClassName(v8_str("MyClass"));
13348
13349 Local<String> customized_tostring = v8_str("customized toString");
13350
13351 // Replace Object.prototype.toString
13352 CompileRun(
13353 "Object.prototype.toString = function() {"
13354 " return 'customized toString';"
13355 "}");
13356
13357 // Normal ToString call should call replaced Object.prototype.toString
13358 Local<v8::Object> instance = templ->GetFunction(context.local())
13359 .ToLocalChecked()
13360 ->NewInstance(context.local())
13361 .ToLocalChecked();
13362 Local<String> value = instance->ToString(context.local()).ToLocalChecked();
13363 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), customized_tostring).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13364, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), customized_tostring).FromJust()"
); } } while (0)
13364 value->Equals(context.local(), customized_tostring).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), customized_tostring).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13364, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), customized_tostring).FromJust()"
); } } while (0)
;
13365
13366 // ObjectProtoToString should not call replace toString function.
13367 value = instance->ObjectProtoToString(context.local()).ToLocalChecked();
13368 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object MyClass]")
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
13369, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object MyClass]\")).FromJust()"
); } } while (0)
13369 value->Equals(context.local(), v8_str("[object MyClass]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object MyClass]")
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
13369, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object MyClass]\")).FromJust()"
); } } while (0)
;
13370
13371 // Check global
13372 value =
13373 context->Global()->ObjectProtoToString(context.local()).ToLocalChecked();
13374 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object global]"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13375
, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object global]\")).FromJust()"
); } } while (0)
13375 value->Equals(context.local(), v8_str("[object global]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object global]"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13375
, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object global]\")).FromJust()"
); } } while (0)
;
13376
13377 // Check ordinary object
13378 Local<Value> object = CompileRun("new Object()");
13379 value = object.As<v8::Object>()
13380 ->ObjectProtoToString(context.local())
13381 .ToLocalChecked();
13382 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Object]"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13383
, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object Object]\")).FromJust()"
); } } while (0)
13383 value->Equals(context.local(), v8_str("[object Object]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Object]"))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13383
, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object Object]\")).FromJust()"
); } } while (0)
;
13384
13385 // Check that ES6 semantics using @@toStringTag work
13386 Local<v8::Symbol> toStringTag = v8::Symbol::GetToStringTag(isolate);
13387
13388#define TEST_TOSTRINGTAG(type, tag, expected) \
13389 do { \
13390 object = CompileRun("new " #type "()"); \
13391 CHECK(object.As<v8::Object>() \do { if ((__builtin_expect(!!(!(object.As<v8::Object>()
->Set(context.local(), toStringTag, v8_str(#tag)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13393, "Check failed: %s."
, "object.As<v8::Object>() ->Set(context.local(), toStringTag, v8_str(#tag)) .FromJust()"
); } } while (0)
13392 ->Set(context.local(), toStringTag, v8_str(#tag)) \do { if ((__builtin_expect(!!(!(object.As<v8::Object>()
->Set(context.local(), toStringTag, v8_str(#tag)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13393, "Check failed: %s."
, "object.As<v8::Object>() ->Set(context.local(), toStringTag, v8_str(#tag)) .FromJust()"
); } } while (0)
13393 .FromJust())do { if ((__builtin_expect(!!(!(object.As<v8::Object>()
->Set(context.local(), toStringTag, v8_str(#tag)) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13393, "Check failed: %s."
, "object.As<v8::Object>() ->Set(context.local(), toStringTag, v8_str(#tag)) .FromJust()"
); } } while (0)
; \
13394 value = object.As<v8::Object>() \
13395 ->ObjectProtoToString(context.local()) \
13396 .ToLocalChecked(); \
13397 CHECK(value->IsString() && \do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object " #expected
"]")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13399, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object \" #expected \"]\")) .FromJust()"
); } } while (0)
13398 value->Equals(context.local(), v8_str("[object " #expected "]")) \do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object " #expected
"]")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13399, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object \" #expected \"]\")) .FromJust()"
); } } while (0)
13399 .FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object " #expected
"]")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13399, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object \" #expected \"]\")) .FromJust()"
); } } while (0)
; \
13400 } while (0)
13401
13402 TEST_TOSTRINGTAG(Array, Object, Object);
13403 TEST_TOSTRINGTAG(Object, Arguments, Arguments);
13404 TEST_TOSTRINGTAG(Object, Array, Array);
13405 TEST_TOSTRINGTAG(Object, Boolean, Boolean);
13406 TEST_TOSTRINGTAG(Object, Date, Date);
13407 TEST_TOSTRINGTAG(Object, Error, Error);
13408 TEST_TOSTRINGTAG(Object, Function, Function);
13409 TEST_TOSTRINGTAG(Object, Number, Number);
13410 TEST_TOSTRINGTAG(Object, RegExp, RegExp);
13411 TEST_TOSTRINGTAG(Object, String, String);
13412 TEST_TOSTRINGTAG(Object, Foo, Foo);
13413
13414#undef TEST_TOSTRINGTAG
13415
13416 Local<v8::RegExp> valueRegExp =
13417 v8::RegExp::New(context.local(), v8_str("^$"), v8::RegExp::kNone)
13418 .ToLocalChecked();
13419 Local<Value> valueNumber = v8_num(123);
13420 Local<v8::Symbol> valueSymbol = v8_symbol("TestSymbol");
13421 Local<v8::Function> valueFunction =
13422 CompileRun("(function fn() {})").As<v8::Function>();
13423 Local<v8::Object> valueObject = v8::Object::New(v8::Isolate::GetCurrent());
13424 Local<v8::Primitive> valueNull = v8::Null(v8::Isolate::GetCurrent());
13425 Local<v8::Primitive> valueUndef = v8::Undefined(v8::Isolate::GetCurrent());
13426
13427#define TEST_TOSTRINGTAG(type, tagValue, expected) \
13428 do { \
13429 object = CompileRun("new " #type "()"); \
13430 CHECK(object.As<v8::Object>() \do { if ((__builtin_expect(!!(!(object.As<v8::Object>()
->Set(context.local(), toStringTag, tagValue) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13432, "Check failed: %s."
, "object.As<v8::Object>() ->Set(context.local(), toStringTag, tagValue) .FromJust()"
); } } while (0)
13431 ->Set(context.local(), toStringTag, tagValue) \do { if ((__builtin_expect(!!(!(object.As<v8::Object>()
->Set(context.local(), toStringTag, tagValue) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13432, "Check failed: %s."
, "object.As<v8::Object>() ->Set(context.local(), toStringTag, tagValue) .FromJust()"
); } } while (0)
13432 .FromJust())do { if ((__builtin_expect(!!(!(object.As<v8::Object>()
->Set(context.local(), toStringTag, tagValue) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13432, "Check failed: %s."
, "object.As<v8::Object>() ->Set(context.local(), toStringTag, tagValue) .FromJust()"
); } } while (0)
; \
13433 value = object.As<v8::Object>() \
13434 ->ObjectProtoToString(context.local()) \
13435 .ToLocalChecked(); \
13436 CHECK(value->IsString() && \do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object " #expected
"]")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13438, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object \" #expected \"]\")) .FromJust()"
); } } while (0)
13437 value->Equals(context.local(), v8_str("[object " #expected "]")) \do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object " #expected
"]")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13438, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object \" #expected \"]\")) .FromJust()"
); } } while (0)
13438 .FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object " #expected
"]")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13438, "Check failed: %s.", "value->IsString() && value->Equals(context.local(), v8_str(\"[object \" #expected \"]\")) .FromJust()"
); } } while (0)
; \
13439 } while (0)
13440
13441#define TEST_TOSTRINGTAG_TYPES(tagValue) \
13442 TEST_TOSTRINGTAG(Array, tagValue, Array); \
13443 TEST_TOSTRINGTAG(Object, tagValue, Object); \
13444 TEST_TOSTRINGTAG(Function, tagValue, Function); \
13445 TEST_TOSTRINGTAG(Date, tagValue, Date); \
13446 TEST_TOSTRINGTAG(RegExp, tagValue, RegExp); \
13447 TEST_TOSTRINGTAG(Error, tagValue, Error); \
13448
13449 // Test non-String-valued @@toStringTag
13450 TEST_TOSTRINGTAG_TYPES(valueRegExp);
13451 TEST_TOSTRINGTAG_TYPES(valueNumber);
13452 TEST_TOSTRINGTAG_TYPES(valueSymbol);
13453 TEST_TOSTRINGTAG_TYPES(valueFunction);
13454 TEST_TOSTRINGTAG_TYPES(valueObject);
13455 TEST_TOSTRINGTAG_TYPES(valueNull);
13456 TEST_TOSTRINGTAG_TYPES(valueUndef);
13457
13458#undef TEST_TOSTRINGTAG
13459#undef TEST_TOSTRINGTAG_TYPES
13460
13461 // @@toStringTag getter throws
13462 Local<Value> obj = v8::Object::New(isolate);
13463 obj.As<v8::Object>()
13464 ->SetAccessor(context.local(), toStringTag, ThrowingSymbolAccessorGetter)
13465 .FromJust();
13466 {
13467 TryCatch try_catch(isolate);
13468 CHECK(obj.As<v8::Object>()->ObjectProtoToString(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(obj.As<v8::Object>()->
ObjectProtoToString(context.local()).IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13468, "Check failed: %s.", "obj.As<v8::Object>()->ObjectProtoToString(context.local()).IsEmpty()"
); } } while (0)
;
13469 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 13469, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
13470 }
13471
13472 // @@toStringTag getter does not throw
13473 obj = v8::Object::New(isolate);
13474 obj.As<v8::Object>()
13475 ->SetAccessor(context.local(), toStringTag,
13476 SymbolAccessorGetterReturnsDefault, 0, v8_str("Test"))
13477 .FromJust();
13478 {
13479 TryCatch try_catch(isolate);
13480 value = obj.As<v8::Object>()
13481 ->ObjectProtoToString(context.local())
13482 .ToLocalChecked();
13483 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Test]")).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13484, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), v8_str(\"[object Test]\")).FromJust()"
); } } while (0)
13484 value->Equals(context.local(), v8_str("[object Test]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Test]")).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13484, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), v8_str(\"[object Test]\")).FromJust()"
); } } while (0)
;
13485 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 13485, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
13486 }
13487
13488 // JS @@toStringTag value
13489 obj = CompileRun("obj = {}; obj[Symbol.toStringTag] = 'Test'; obj");
13490 {
13491 TryCatch try_catch(isolate);
13492 value = obj.As<v8::Object>()
13493 ->ObjectProtoToString(context.local())
13494 .ToLocalChecked();
13495 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Test]")).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13496, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), v8_str(\"[object Test]\")).FromJust()"
); } } while (0)
13496 value->Equals(context.local(), v8_str("[object Test]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Test]")).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13496, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), v8_str(\"[object Test]\")).FromJust()"
); } } while (0)
;
13497 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 13497, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
13498 }
13499
13500 // JS @@toStringTag getter throws
13501 obj = CompileRun(
13502 "obj = {}; Object.defineProperty(obj, Symbol.toStringTag, {"
13503 " get: function() { throw 'Test'; }"
13504 "}); obj");
13505 {
13506 TryCatch try_catch(isolate);
13507 CHECK(obj.As<v8::Object>()->ObjectProtoToString(context.local()).IsEmpty())do { if ((__builtin_expect(!!(!(obj.As<v8::Object>()->
ObjectProtoToString(context.local()).IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13507, "Check failed: %s.", "obj.As<v8::Object>()->ObjectProtoToString(context.local()).IsEmpty()"
); } } while (0)
;
13508 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 13508, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
13509 }
13510
13511 // JS @@toStringTag getter does not throw
13512 obj = CompileRun(
13513 "obj = {}; Object.defineProperty(obj, Symbol.toStringTag, {"
13514 " get: function() { return 'Test'; }"
13515 "}); obj");
13516 {
13517 TryCatch try_catch(isolate);
13518 value = obj.As<v8::Object>()
13519 ->ObjectProtoToString(context.local())
13520 .ToLocalChecked();
13521 CHECK(value->IsString() &&do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Test]")).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13522, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), v8_str(\"[object Test]\")).FromJust()"
); } } while (0)
13522 value->Equals(context.local(), v8_str("[object Test]")).FromJust())do { if ((__builtin_expect(!!(!(value->IsString() &&
value->Equals(context.local(), v8_str("[object Test]")).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13522, "Check failed: %s."
, "value->IsString() && value->Equals(context.local(), v8_str(\"[object Test]\")).FromJust()"
); } } while (0)
;
13523 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 13523, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
13524 }
13525}
13526
13527
13528THREADED_TEST(ObjectGetConstructorName)static void TestObjectGetConstructorName(); RegisterThreadedTest
register_ObjectGetConstructorName(TestObjectGetConstructorName
, "ObjectGetConstructorName"); static void TestObjectGetConstructorName
(); CcTest register_test_ObjectGetConstructorName(TestObjectGetConstructorName
, "../test/cctest/test-api.cc", "ObjectGetConstructorName", __null
, true, true); static void TestObjectGetConstructorName()
{
13529 v8::Isolate* isolate = CcTest::isolate();
13530 LocalContext context;
13531 v8::HandleScope scope(isolate);
13532 v8_compile(
13533 "function Parent() {};"
13534 "function Child() {};"
13535 "Child.prototype = new Parent();"
13536 "Child.prototype.constructor = Child;"
13537 "var outer = { inner: function() { } };"
13538 "var p = new Parent();"
13539 "var c = new Child();"
13540 "var x = new outer.inner();"
13541 "var proto = Child.prototype;")
13542 ->Run(context.local())
13543 .ToLocalChecked();
13544
13545 Local<v8::Value> p =
13546 context->Global()->Get(context.local(), v8_str("p")).ToLocalChecked();
13547 CHECK(p->IsObject() &&do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13552, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13548 p->ToObject(context.local())do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13552, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13549 .ToLocalChecked()do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13552, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13550 ->GetConstructorName()do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13552, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13551 ->Equals(context.local(), v8_str("Parent"))do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13552, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13552 .FromJust())do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13552, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
;
13553
13554 Local<v8::Value> c =
13555 context->Global()->Get(context.local(), v8_str("c")).ToLocalChecked();
13556 CHECK(c->IsObject() &&do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13561, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13557 c->ToObject(context.local())do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13561, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13558 .ToLocalChecked()do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13561, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13559 ->GetConstructorName()do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13561, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13560 ->Equals(context.local(), v8_str("Child"))do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13561, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13561 .FromJust())do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13561, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
;
13562
13563 Local<v8::Value> x =
13564 context->Global()->Get(context.local(), v8_str("x")).ToLocalChecked();
13565 CHECK(x->IsObject() &&do { if ((__builtin_expect(!!(!(x->IsObject() && x
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("outer.inner")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13570, "Check failed: %s."
, "x->IsObject() && x->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"outer.inner\")) .FromJust()"
); } } while (0)
13566 x->ToObject(context.local())do { if ((__builtin_expect(!!(!(x->IsObject() && x
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("outer.inner")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13570, "Check failed: %s."
, "x->IsObject() && x->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"outer.inner\")) .FromJust()"
); } } while (0)
13567 .ToLocalChecked()do { if ((__builtin_expect(!!(!(x->IsObject() && x
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("outer.inner")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13570, "Check failed: %s."
, "x->IsObject() && x->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"outer.inner\")) .FromJust()"
); } } while (0)
13568 ->GetConstructorName()do { if ((__builtin_expect(!!(!(x->IsObject() && x
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("outer.inner")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13570, "Check failed: %s."
, "x->IsObject() && x->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"outer.inner\")) .FromJust()"
); } } while (0)
13569 ->Equals(context.local(), v8_str("outer.inner"))do { if ((__builtin_expect(!!(!(x->IsObject() && x
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("outer.inner")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13570, "Check failed: %s."
, "x->IsObject() && x->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"outer.inner\")) .FromJust()"
); } } while (0)
13570 .FromJust())do { if ((__builtin_expect(!!(!(x->IsObject() && x
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("outer.inner")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13570, "Check failed: %s."
, "x->IsObject() && x->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"outer.inner\")) .FromJust()"
); } } while (0)
;
13571
13572 Local<v8::Value> child_prototype =
13573 context->Global()->Get(context.local(), v8_str("proto")).ToLocalChecked();
13574 CHECK(child_prototype->IsObject() &&do { if ((__builtin_expect(!!(!(child_prototype->IsObject(
) && child_prototype->ToObject(context.local()) .ToLocalChecked
() ->GetConstructorName() ->Equals(context.local(), v8_str
("Parent")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13579, "Check failed: %s.", "child_prototype->IsObject() && child_prototype->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13575 child_prototype->ToObject(context.local())do { if ((__builtin_expect(!!(!(child_prototype->IsObject(
) && child_prototype->ToObject(context.local()) .ToLocalChecked
() ->GetConstructorName() ->Equals(context.local(), v8_str
("Parent")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13579, "Check failed: %s.", "child_prototype->IsObject() && child_prototype->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13576 .ToLocalChecked()do { if ((__builtin_expect(!!(!(child_prototype->IsObject(
) && child_prototype->ToObject(context.local()) .ToLocalChecked
() ->GetConstructorName() ->Equals(context.local(), v8_str
("Parent")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13579, "Check failed: %s.", "child_prototype->IsObject() && child_prototype->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13577 ->GetConstructorName()do { if ((__builtin_expect(!!(!(child_prototype->IsObject(
) && child_prototype->ToObject(context.local()) .ToLocalChecked
() ->GetConstructorName() ->Equals(context.local(), v8_str
("Parent")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13579, "Check failed: %s.", "child_prototype->IsObject() && child_prototype->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13578 ->Equals(context.local(), v8_str("Parent"))do { if ((__builtin_expect(!!(!(child_prototype->IsObject(
) && child_prototype->ToObject(context.local()) .ToLocalChecked
() ->GetConstructorName() ->Equals(context.local(), v8_str
("Parent")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13579, "Check failed: %s.", "child_prototype->IsObject() && child_prototype->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13579 .FromJust())do { if ((__builtin_expect(!!(!(child_prototype->IsObject(
) && child_prototype->ToObject(context.local()) .ToLocalChecked
() ->GetConstructorName() ->Equals(context.local(), v8_str
("Parent")) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 13579, "Check failed: %s.", "child_prototype->IsObject() && child_prototype->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
;
13580}
13581
13582
13583THREADED_TEST(SubclassGetConstructorName)static void TestSubclassGetConstructorName(); RegisterThreadedTest
register_SubclassGetConstructorName(TestSubclassGetConstructorName
, "SubclassGetConstructorName"); static void TestSubclassGetConstructorName
(); CcTest register_test_SubclassGetConstructorName(TestSubclassGetConstructorName
, "../test/cctest/test-api.cc", "SubclassGetConstructorName",
__null, true, true); static void TestSubclassGetConstructorName
()
{
13584 v8::Isolate* isolate = CcTest::isolate();
13585 LocalContext context;
13586 v8::HandleScope scope(isolate);
13587 v8_compile(
13588 "\"use strict\";"
13589 "class Parent {}"
13590 "class Child extends Parent {}"
13591 "var p = new Parent();"
13592 "var c = new Child();")
13593 ->Run(context.local())
13594 .ToLocalChecked();
13595
13596 Local<v8::Value> p =
13597 context->Global()->Get(context.local(), v8_str("p")).ToLocalChecked();
13598 CHECK(p->IsObject() &&do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13603, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13599 p->ToObject(context.local())do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13603, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13600 .ToLocalChecked()do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13603, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13601 ->GetConstructorName()do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13603, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13602 ->Equals(context.local(), v8_str("Parent"))do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13603, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
13603 .FromJust())do { if ((__builtin_expect(!!(!(p->IsObject() && p
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Parent")) .FromJust()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13603, "Check failed: %s."
, "p->IsObject() && p->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Parent\")) .FromJust()"
); } } while (0)
;
13604
13605 Local<v8::Value> c =
13606 context->Global()->Get(context.local(), v8_str("c")).ToLocalChecked();
13607 CHECK(c->IsObject() &&do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13612, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13608 c->ToObject(context.local())do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13612, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13609 .ToLocalChecked()do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13612, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13610 ->GetConstructorName()do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13612, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13611 ->Equals(context.local(), v8_str("Child"))do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13612, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
13612 .FromJust())do { if ((__builtin_expect(!!(!(c->IsObject() && c
->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName
() ->Equals(context.local(), v8_str("Child")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13612, "Check failed: %s."
, "c->IsObject() && c->ToObject(context.local()) .ToLocalChecked() ->GetConstructorName() ->Equals(context.local(), v8_str(\"Child\")) .FromJust()"
); } } while (0)
;
13613}
13614
13615
13616bool ApiTestFuzzer::fuzzing_ = false;
13617v8::base::Semaphore ApiTestFuzzer::all_tests_done_(0);
13618int ApiTestFuzzer::active_tests_;
13619int ApiTestFuzzer::tests_being_run_;
13620int ApiTestFuzzer::current_;
13621
13622
13623// We are in a callback and want to switch to another thread (if we
13624// are currently running the thread fuzzing test).
13625void ApiTestFuzzer::Fuzz() {
13626 if (!fuzzing_) return;
13627 ApiTestFuzzer* test = RegisterThreadedTest::nth(current_)->fuzzer_;
13628 test->ContextSwitch();
13629}
13630
13631
13632// Let the next thread go. Since it is also waiting on the V8 lock it may
13633// not start immediately.
13634bool ApiTestFuzzer::NextThread() {
13635 int test_position = GetNextTestNumber();
13636 const char* test_name = RegisterThreadedTest::nth(current_)->name();
13637 if (test_position == current_) {
13638 if (kLogThreading)
13639 printf("Stay with %s\n", test_name);
13640 return false;
13641 }
13642 if (kLogThreading) {
13643 printf("Switch from %s to %s\n",
13644 test_name,
13645 RegisterThreadedTest::nth(test_position)->name());
13646 }
13647 current_ = test_position;
13648 RegisterThreadedTest::nth(current_)->fuzzer_->gate_.Signal();
13649 return true;
13650}
13651
13652
13653void ApiTestFuzzer::Run() {
13654 // When it is our turn...
13655 gate_.Wait();
13656 {
13657 // ... get the V8 lock and start running the test.
13658 v8::Locker locker(CcTest::isolate());
13659 CallTest();
13660 }
13661 // This test finished.
13662 active_ = false;
13663 active_tests_--;
13664 // If it was the last then signal that fact.
13665 if (active_tests_ == 0) {
13666 all_tests_done_.Signal();
13667 } else {
13668 // Otherwise select a new test and start that.
13669 NextThread();
13670 }
13671}
13672
13673
13674static unsigned linear_congruential_generator;
13675
13676
13677void ApiTestFuzzer::SetUp(PartOfTest part) {
13678 linear_congruential_generator = i::FLAG_testing_prng_seed;
13679 fuzzing_ = true;
13680 int count = RegisterThreadedTest::count();
13681 int start = count * part / (LAST_PART + 1);
13682 int end = (count * (part + 1) / (LAST_PART + 1)) - 1;
13683 active_tests_ = tests_being_run_ = end - start + 1;
13684 for (int i = 0; i < tests_being_run_; i++) {
13685 RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer(i + start);
13686 }
13687 for (int i = 0; i < active_tests_; i++) {
13688 RegisterThreadedTest::nth(i)->fuzzer_->Start();
13689 }
13690}
13691
13692
13693static void CallTestNumber(int test_number) {
13694 (RegisterThreadedTest::nth(test_number)->callback())();
13695}
13696
13697
13698void ApiTestFuzzer::RunAllTests() {
13699 // Set off the first test.
13700 current_ = -1;
13701 NextThread();
13702 // Wait till they are all done.
13703 all_tests_done_.Wait();
13704}
13705
13706
13707int ApiTestFuzzer::GetNextTestNumber() {
13708 int next_test;
13709 do {
13710 next_test = (linear_congruential_generator >> 16) % tests_being_run_;
13711 linear_congruential_generator *= 1664525u;
13712 linear_congruential_generator += 1013904223u;
13713 } while (!RegisterThreadedTest::nth(next_test)->fuzzer_->active_);
13714 return next_test;
13715}
13716
13717
13718void ApiTestFuzzer::ContextSwitch() {
13719 // If the new thread is the same as the current thread there is nothing to do.
13720 if (NextThread()) {
13721 // Now it can start.
13722 v8::Unlocker unlocker(CcTest::isolate());
13723 // Wait till someone starts us again.
13724 gate_.Wait();
13725 // And we're off.
13726 }
13727}
13728
13729
13730void ApiTestFuzzer::TearDown() {
13731 fuzzing_ = false;
13732 for (int i = 0; i < RegisterThreadedTest::count(); i++) {
13733 ApiTestFuzzer *fuzzer = RegisterThreadedTest::nth(i)->fuzzer_;
13734 if (fuzzer != NULL__null) fuzzer->Join();
13735 }
13736}
13737
13738
13739// Lets not be needlessly self-referential.
13740TEST(Threading1)static void TestThreading1(); CcTest register_test_Threading1
(TestThreading1, "../test/cctest/test-api.cc", "Threading1", __null
, true, true); static void TestThreading1()
{
13741 ApiTestFuzzer::SetUp(ApiTestFuzzer::FIRST_PART);
13742 ApiTestFuzzer::RunAllTests();
13743 ApiTestFuzzer::TearDown();
13744}
13745
13746
13747TEST(Threading2)static void TestThreading2(); CcTest register_test_Threading2
(TestThreading2, "../test/cctest/test-api.cc", "Threading2", __null
, true, true); static void TestThreading2()
{
13748 ApiTestFuzzer::SetUp(ApiTestFuzzer::SECOND_PART);
13749 ApiTestFuzzer::RunAllTests();
13750 ApiTestFuzzer::TearDown();
13751}
13752
13753
13754TEST(Threading3)static void TestThreading3(); CcTest register_test_Threading3
(TestThreading3, "../test/cctest/test-api.cc", "Threading3", __null
, true, true); static void TestThreading3()
{
13755 ApiTestFuzzer::SetUp(ApiTestFuzzer::THIRD_PART);
13756 ApiTestFuzzer::RunAllTests();
13757 ApiTestFuzzer::TearDown();
13758}
13759
13760
13761TEST(Threading4)static void TestThreading4(); CcTest register_test_Threading4
(TestThreading4, "../test/cctest/test-api.cc", "Threading4", __null
, true, true); static void TestThreading4()
{
13762 ApiTestFuzzer::SetUp(ApiTestFuzzer::FOURTH_PART);
13763 ApiTestFuzzer::RunAllTests();
13764 ApiTestFuzzer::TearDown();
13765}
13766
13767
13768void ApiTestFuzzer::CallTest() {
13769 v8::Isolate::Scope scope(CcTest::isolate());
13770 if (kLogThreading)
13771 printf("Start test %d\n", test_number_);
13772 CallTestNumber(test_number_);
13773 if (kLogThreading)
13774 printf("End test %d\n", test_number_);
13775}
13776
13777
13778static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) {
13779 v8::Isolate* isolate = args.GetIsolate();
13780 CHECK(v8::Locker::IsLocked(isolate))do { if ((__builtin_expect(!!(!(v8::Locker::IsLocked(isolate)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13780, "Check failed: %s."
, "v8::Locker::IsLocked(isolate)"); } } while (0)
;
13781 ApiTestFuzzer::Fuzz();
13782 v8::Unlocker unlocker(isolate);
13783 const char* code = "throw 7;";
13784 {
13785 v8::Locker nested_locker(isolate);
13786 v8::HandleScope scope(isolate);
13787 v8::Local<Value> exception;
13788 {
13789 v8::TryCatch try_catch(isolate);
13790 v8::Local<Value> value = CompileRun(code);
13791 CHECK(value.IsEmpty())do { if ((__builtin_expect(!!(!(value.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13791, "Check failed: %s.", "value.IsEmpty()"
); } } while (0)
;
13792 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 13792, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
13793 // Make sure to wrap the exception in a new handle because
13794 // the handle returned from the TryCatch is destroyed
13795 // when the TryCatch is destroyed.
13796 exception = Local<Value>::New(isolate, try_catch.Exception());
13797 }
13798 args.GetIsolate()->ThrowException(exception);
13799 }
13800}
13801
13802
13803static void ThrowInJSNoCatch(const v8::FunctionCallbackInfo<v8::Value>& args) {
13804 CHECK(v8::Locker::IsLocked(CcTest::isolate()))do { if ((__builtin_expect(!!(!(v8::Locker::IsLocked(CcTest::
isolate()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13804
, "Check failed: %s.", "v8::Locker::IsLocked(CcTest::isolate())"
); } } while (0)
;
13805 ApiTestFuzzer::Fuzz();
13806 v8::Unlocker unlocker(CcTest::isolate());
13807 const char* code = "throw 7;";
13808 {
13809 v8::Locker nested_locker(CcTest::isolate());
13810 v8::HandleScope scope(args.GetIsolate());
13811 v8::Local<Value> value = CompileRun(code);
13812 CHECK(value.IsEmpty())do { if ((__builtin_expect(!!(!(value.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13812, "Check failed: %s.", "value.IsEmpty()"
); } } while (0)
;
13813 args.GetReturnValue().Set(v8_str("foo"));
13814 }
13815}
13816
13817
13818// These are locking tests that don't need to be run again
13819// as part of the locking aggregation tests.
13820TEST(NestedLockers)static void TestNestedLockers(); CcTest register_test_NestedLockers
(TestNestedLockers, "../test/cctest/test-api.cc", "NestedLockers"
, __null, true, true); static void TestNestedLockers()
{
13821 v8::Isolate* isolate = CcTest::isolate();
13822 v8::Locker locker(isolate);
13823 CHECK(v8::Locker::IsLocked(isolate))do { if ((__builtin_expect(!!(!(v8::Locker::IsLocked(isolate)
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13823, "Check failed: %s."
, "v8::Locker::IsLocked(isolate)"); } } while (0)
;
13824 LocalContext env;
13825 v8::HandleScope scope(env->GetIsolate());
13826 Local<v8::FunctionTemplate> fun_templ =
13827 v8::FunctionTemplate::New(isolate, ThrowInJS);
13828 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
13829 CHECK(env->Global()->Set(env.local(), v8_str("throw_in_js"), fun).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("throw_in_js"), fun).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13829, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"throw_in_js\"), fun).FromJust()"
); } } while (0)
;
13830 Local<Script> script = v8_compile("(function () {"
13831 " try {"
13832 " throw_in_js();"
13833 " return 42;"
13834 " } catch (e) {"
13835 " return e * 13;"
13836 " }"
13837 "})();");
13838 CHECK_EQ(91, script->Run(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "91" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13841, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13839 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "91" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13841, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13840 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "91" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13841, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13841 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "91" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13841, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
13842}
13843
13844
13845// These are locking tests that don't need to be run again
13846// as part of the locking aggregation tests.
13847TEST(NestedLockersNoTryCatch)static void TestNestedLockersNoTryCatch(); CcTest register_test_NestedLockersNoTryCatch
(TestNestedLockersNoTryCatch, "../test/cctest/test-api.cc", "NestedLockersNoTryCatch"
, __null, true, true); static void TestNestedLockersNoTryCatch
()
{
13848 v8::Locker locker(CcTest::isolate());
13849 LocalContext env;
13850 v8::HandleScope scope(env->GetIsolate());
13851 Local<v8::FunctionTemplate> fun_templ =
13852 v8::FunctionTemplate::New(env->GetIsolate(), ThrowInJSNoCatch);
13853 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
13854 CHECK(env->Global()->Set(env.local(), v8_str("throw_in_js"), fun).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("throw_in_js"), fun).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 13854, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"throw_in_js\"), fun).FromJust()"
); } } while (0)
;
13855 Local<Script> script = v8_compile("(function () {"
13856 " try {"
13857 " throw_in_js();"
13858 " return 42;"
13859 " } catch (e) {"
13860 " return e * 13;"
13861 " }"
13862 "})();");
13863 CHECK_EQ(91, script->Run(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "91" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13866, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13864 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "91" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13866, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13865 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "91" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13866, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13866 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "91" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13866, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
13867}
13868
13869
13870THREADED_TEST(RecursiveLocking)static void TestRecursiveLocking(); RegisterThreadedTest register_RecursiveLocking
(TestRecursiveLocking, "RecursiveLocking"); static void TestRecursiveLocking
(); CcTest register_test_RecursiveLocking(TestRecursiveLocking
, "../test/cctest/test-api.cc", "RecursiveLocking", __null, true
, true); static void TestRecursiveLocking()
{
13871 v8::Locker locker(CcTest::isolate());
13872 {
13873 v8::Locker locker2(CcTest::isolate());
13874 CHECK(v8::Locker::IsLocked(CcTest::isolate()))do { if ((__builtin_expect(!!(!(v8::Locker::IsLocked(CcTest::
isolate()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 13874
, "Check failed: %s.", "v8::Locker::IsLocked(CcTest::isolate())"
); } } while (0)
;
13875 }
13876}
13877
13878
13879static void UnlockForAMoment(const v8::FunctionCallbackInfo<v8::Value>& args) {
13880 ApiTestFuzzer::Fuzz();
13881 v8::Unlocker unlocker(CcTest::isolate());
13882}
13883
13884
13885THREADED_TEST(LockUnlockLock)static void TestLockUnlockLock(); RegisterThreadedTest register_LockUnlockLock
(TestLockUnlockLock, "LockUnlockLock"); static void TestLockUnlockLock
(); CcTest register_test_LockUnlockLock(TestLockUnlockLock, "../test/cctest/test-api.cc"
, "LockUnlockLock", __null, true, true); static void TestLockUnlockLock
()
{
13886 {
13887 v8::Locker locker(CcTest::isolate());
13888 v8::HandleScope scope(CcTest::isolate());
13889 LocalContext env;
13890 Local<v8::FunctionTemplate> fun_templ =
13891 v8::FunctionTemplate::New(CcTest::isolate(), UnlockForAMoment);
13892 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
13893 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("unlock_for_a_moment"), fun) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 13895, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"unlock_for_a_moment\"), fun) .FromJust()"
); } } while (0)
13894 ->Set(env.local(), v8_str("unlock_for_a_moment"), fun)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("unlock_for_a_moment"), fun) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 13895, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"unlock_for_a_moment\"), fun) .FromJust()"
); } } while (0)
13895 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("unlock_for_a_moment"), fun) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 13895, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"unlock_for_a_moment\"), fun) .FromJust()"
); } } while (0)
;
13896 Local<Script> script = v8_compile("(function () {"
13897 " unlock_for_a_moment();"
13898 " return 42;"
13899 "})();");
13900 CHECK_EQ(42, script->Run(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13901 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13902 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13903 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
13904 }
13905 {
13906 v8::Locker locker(CcTest::isolate());
13907 v8::HandleScope scope(CcTest::isolate());
13908 LocalContext env;
13909 Local<v8::FunctionTemplate> fun_templ =
13910 v8::FunctionTemplate::New(CcTest::isolate(), UnlockForAMoment);
13911 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
13912 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("unlock_for_a_moment"), fun) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 13914, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"unlock_for_a_moment\"), fun) .FromJust()"
); } } while (0)
13913 ->Set(env.local(), v8_str("unlock_for_a_moment"), fun)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("unlock_for_a_moment"), fun) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 13914, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"unlock_for_a_moment\"), fun) .FromJust()"
); } } while (0)
13914 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("unlock_for_a_moment"), fun) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 13914, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"unlock_for_a_moment\"), fun) .FromJust()"
); } } while (0)
;
13915 Local<Script> script = v8_compile("(function () {"
13916 " unlock_for_a_moment();"
13917 " return 42;"
13918 "})();");
13919 CHECK_EQ(42, script->Run(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13922, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13920 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13922, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13921 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13922, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
13922 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(env.local()) .ToLocalChecked() ->Int32Value
(env.local()) .FromJust()), "42" " " "==" " " "script->Run(env.local()) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 13922, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
13923 }
13924}
13925
13926
13927static int GetGlobalObjectsCount() {
13928 int count = 0;
13929 i::HeapIterator it(CcTest::heap());
13930 for (i::HeapObject* object = it.next(); object != NULL__null; object = it.next())
13931 if (object->IsJSGlobalObject()) {
13932 i::JSGlobalObject* g = i::JSGlobalObject::cast(object);
13933 // Skip dummy global object.
13934 if (i::GlobalDictionary::cast(g->properties())->NumberOfElements() != 0) {
13935 count++;
13936 }
13937 }
13938 return count;
13939}
13940
13941
13942static void CheckSurvivingGlobalObjectsCount(int expected) {
13943 // We need to collect all garbage twice to be sure that everything
13944 // has been collected. This is because inline caches are cleared in
13945 // the first garbage collection but some of the maps have already
13946 // been marked at that point. Therefore some of the maps are not
13947 // collected until the second garbage collection.
13948 CcTest::heap()->CollectAllGarbage();
13949 CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
13950 int count = GetGlobalObjectsCount();
13951#ifdef DEBUG1
13952 if (count != expected) CcTest::heap()->TracePathToGlobal();
13953#endif
13954 CHECK_EQ(expected, count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected
), (count), "expected" " " "==" " " "count")) { V8_Fatal("../test/cctest/test-api.cc"
, 13954, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
13955}
13956
13957
13958TEST(DontLeakGlobalObjects)static void TestDontLeakGlobalObjects(); CcTest register_test_DontLeakGlobalObjects
(TestDontLeakGlobalObjects, "../test/cctest/test-api.cc", "DontLeakGlobalObjects"
, __null, true, true); static void TestDontLeakGlobalObjects(
)
{
13959 // Regression test for issues 1139850 and 1174891.
13960
13961 i::FLAG_expose_gc = true;
13962 v8::V8::Initialize();
13963
13964 for (int i = 0; i < 5; i++) {
13965 { v8::HandleScope scope(CcTest::isolate());
13966 LocalContext context;
13967 }
13968 CcTest::isolate()->ContextDisposedNotification();
13969 CheckSurvivingGlobalObjectsCount(0);
13970
13971 { v8::HandleScope scope(CcTest::isolate());
13972 LocalContext context;
13973 v8_compile("Date")->Run(context.local()).ToLocalChecked();
13974 }
13975 CcTest::isolate()->ContextDisposedNotification();
13976 CheckSurvivingGlobalObjectsCount(0);
13977
13978 { v8::HandleScope scope(CcTest::isolate());
13979 LocalContext context;
13980 v8_compile("/aaa/")->Run(context.local()).ToLocalChecked();
13981 }
13982 CcTest::isolate()->ContextDisposedNotification();
13983 CheckSurvivingGlobalObjectsCount(0);
13984
13985 { v8::HandleScope scope(CcTest::isolate());
13986 const char* extension_list[] = { "v8/gc" };
13987 v8::ExtensionConfiguration extensions(1, extension_list);
13988 LocalContext context(&extensions);
13989 v8_compile("gc();")->Run(context.local()).ToLocalChecked();
13990 }
13991 CcTest::isolate()->ContextDisposedNotification();
13992 CheckSurvivingGlobalObjectsCount(0);
13993 }
13994}
13995
13996
13997TEST(CopyablePersistent)static void TestCopyablePersistent(); CcTest register_test_CopyablePersistent
(TestCopyablePersistent, "../test/cctest/test-api.cc", "CopyablePersistent"
, __null, true, true); static void TestCopyablePersistent()
{
13998 LocalContext context;
13999 v8::Isolate* isolate = context->GetIsolate();
14000 i::GlobalHandles* globals =
14001 reinterpret_cast<i::Isolate*>(isolate)->global_handles();
14002 int initial_handles = globals->global_handles_count();
14003 typedef v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object> >
14004 CopyableObject;
14005 {
14006 CopyableObject handle1;
14007 {
14008 v8::HandleScope scope(isolate);
14009 handle1.Reset(isolate, v8::Object::New(isolate));
14010 }
14011 CHECK_EQ(initial_handles + 1, globals->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handles
+ 1), (globals->global_handles_count()), "initial_handles + 1"
" " "==" " " "globals->global_handles_count()")) { V8_Fatal
("../test/cctest/test-api.cc", 14011, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
14012 CopyableObject handle2;
14013 handle2 = handle1;
14014 CHECK(handle1 == handle2)do { if ((__builtin_expect(!!(!(handle1 == handle2)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14014, "Check failed: %s.", "handle1 == handle2"
); } } while (0)
;
14015 CHECK_EQ(initial_handles + 2, globals->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handles
+ 2), (globals->global_handles_count()), "initial_handles + 2"
" " "==" " " "globals->global_handles_count()")) { V8_Fatal
("../test/cctest/test-api.cc", 14015, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
14016 CopyableObject handle3(handle2);
14017 CHECK(handle1 == handle3)do { if ((__builtin_expect(!!(!(handle1 == handle3)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14017, "Check failed: %s.", "handle1 == handle3"
); } } while (0)
;
14018 CHECK_EQ(initial_handles + 3, globals->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handles
+ 3), (globals->global_handles_count()), "initial_handles + 3"
" " "==" " " "globals->global_handles_count()")) { V8_Fatal
("../test/cctest/test-api.cc", 14018, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
14019 }
14020 // Verify autodispose
14021 CHECK_EQ(initial_handles, globals->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handles
), (globals->global_handles_count()), "initial_handles" " "
"==" " " "globals->global_handles_count()")) { V8_Fatal("../test/cctest/test-api.cc"
, 14021, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
14022}
14023
14024
14025static void WeakApiCallback(
14026 const v8::WeakCallbackInfo<Persistent<v8::Object>>& data) {
14027 data.GetParameter()->Reset();
14028 delete data.GetParameter();
14029}
14030
14031
14032TEST(WeakCallbackApi)static void TestWeakCallbackApi(); CcTest register_test_WeakCallbackApi
(TestWeakCallbackApi, "../test/cctest/test-api.cc", "WeakCallbackApi"
, __null, true, true); static void TestWeakCallbackApi()
{
14033 LocalContext context;
14034 v8::Isolate* isolate = context->GetIsolate();
14035 i::GlobalHandles* globals =
14036 reinterpret_cast<i::Isolate*>(isolate)->global_handles();
14037 int initial_handles = globals->global_handles_count();
14038 {
14039 v8::HandleScope scope(isolate);
14040 v8::Local<v8::Object> obj = v8::Object::New(isolate);
14041 CHECK(do { if ((__builtin_expect(!!(!(obj->Set(context.local(), v8_str
("key"), v8::Integer::New(isolate, 231)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14043, "Check failed: %s."
, "obj->Set(context.local(), v8_str(\"key\"), v8::Integer::New(isolate, 231)) .FromJust()"
); } } while (0)
14042 obj->Set(context.local(), v8_str("key"), v8::Integer::New(isolate, 231))do { if ((__builtin_expect(!!(!(obj->Set(context.local(), v8_str
("key"), v8::Integer::New(isolate, 231)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14043, "Check failed: %s."
, "obj->Set(context.local(), v8_str(\"key\"), v8::Integer::New(isolate, 231)) .FromJust()"
); } } while (0)
14043 .FromJust())do { if ((__builtin_expect(!!(!(obj->Set(context.local(), v8_str
("key"), v8::Integer::New(isolate, 231)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14043, "Check failed: %s."
, "obj->Set(context.local(), v8_str(\"key\"), v8::Integer::New(isolate, 231)) .FromJust()"
); } } while (0)
;
14044 v8::Persistent<v8::Object>* handle =
14045 new v8::Persistent<v8::Object>(isolate, obj);
14046 handle->SetWeak<v8::Persistent<v8::Object>>(
14047 handle, WeakApiCallback, v8::WeakCallbackType::kParameter);
14048 }
14049 reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage(
14050 i::Heap::kAbortIncrementalMarkingMask);
14051 // Verify disposed.
14052 CHECK_EQ(initial_handles, globals->global_handles_count())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (initial_handles
), (globals->global_handles_count()), "initial_handles" " "
"==" " " "globals->global_handles_count()")) { V8_Fatal("../test/cctest/test-api.cc"
, 14052, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
14053}
14054
14055
14056v8::Persistent<v8::Object> some_object;
14057v8::Persistent<v8::Object> bad_handle;
14058
14059
14060void NewPersistentHandleCallback2(
14061 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
14062 v8::HandleScope scope(data.GetIsolate());
14063 bad_handle.Reset(data.GetIsolate(), some_object);
14064}
14065
14066
14067void NewPersistentHandleCallback1(
14068 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
14069 data.GetParameter()->Reset();
14070 data.SetSecondPassCallback(NewPersistentHandleCallback2);
14071}
14072
14073
14074THREADED_TEST(NewPersistentHandleFromWeakCallback)static void TestNewPersistentHandleFromWeakCallback(); RegisterThreadedTest
register_NewPersistentHandleFromWeakCallback(TestNewPersistentHandleFromWeakCallback
, "NewPersistentHandleFromWeakCallback"); static void TestNewPersistentHandleFromWeakCallback
(); CcTest register_test_NewPersistentHandleFromWeakCallback(
TestNewPersistentHandleFromWeakCallback, "../test/cctest/test-api.cc"
, "NewPersistentHandleFromWeakCallback", __null, true, true);
static void TestNewPersistentHandleFromWeakCallback()
{
14075 LocalContext context;
14076 v8::Isolate* isolate = context->GetIsolate();
14077
14078 v8::Persistent<v8::Object> handle1, handle2;
14079 {
14080 v8::HandleScope scope(isolate);
14081 some_object.Reset(isolate, v8::Object::New(isolate));
14082 handle1.Reset(isolate, v8::Object::New(isolate));
14083 handle2.Reset(isolate, v8::Object::New(isolate));
14084 }
14085 // Note: order is implementation dependent alas: currently
14086 // global handle nodes are processed by PostGarbageCollectionProcessing
14087 // in reverse allocation order, so if second allocated handle is deleted,
14088 // weak callback of the first handle would be able to 'reallocate' it.
14089 handle1.SetWeak(&handle1, NewPersistentHandleCallback1,
14090 v8::WeakCallbackType::kParameter);
14091 handle2.Reset();
14092 CcTest::heap()->CollectAllGarbage();
14093}
14094
14095
14096v8::Persistent<v8::Object> to_be_disposed;
14097
14098
14099void DisposeAndForceGcCallback2(
14100 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
14101 to_be_disposed.Reset();
14102 CcTest::heap()->CollectAllGarbage();
14103}
14104
14105
14106void DisposeAndForceGcCallback1(
14107 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
14108 data.GetParameter()->Reset();
14109 data.SetSecondPassCallback(DisposeAndForceGcCallback2);
14110}
14111
14112
14113THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc)static void TestDoNotUseDeletedNodesInSecondLevelGc(); RegisterThreadedTest
register_DoNotUseDeletedNodesInSecondLevelGc(TestDoNotUseDeletedNodesInSecondLevelGc
, "DoNotUseDeletedNodesInSecondLevelGc"); static void TestDoNotUseDeletedNodesInSecondLevelGc
(); CcTest register_test_DoNotUseDeletedNodesInSecondLevelGc(
TestDoNotUseDeletedNodesInSecondLevelGc, "../test/cctest/test-api.cc"
, "DoNotUseDeletedNodesInSecondLevelGc", __null, true, true);
static void TestDoNotUseDeletedNodesInSecondLevelGc()
{
14114 LocalContext context;
14115 v8::Isolate* isolate = context->GetIsolate();
14116
14117 v8::Persistent<v8::Object> handle1, handle2;
14118 {
14119 v8::HandleScope scope(isolate);
14120 handle1.Reset(isolate, v8::Object::New(isolate));
14121 handle2.Reset(isolate, v8::Object::New(isolate));
14122 }
14123 handle1.SetWeak(&handle1, DisposeAndForceGcCallback1,
14124 v8::WeakCallbackType::kParameter);
14125 to_be_disposed.Reset(isolate, handle2);
14126 CcTest::heap()->CollectAllGarbage();
14127}
14128
14129void DisposingCallback(
14130 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
14131 data.GetParameter()->Reset();
14132}
14133
14134void HandleCreatingCallback2(
14135 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
14136 v8::HandleScope scope(data.GetIsolate());
14137 v8::Global<v8::Object>(data.GetIsolate(), v8::Object::New(data.GetIsolate()));
14138}
14139
14140
14141void HandleCreatingCallback1(
14142 const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
14143 data.GetParameter()->Reset();
14144 data.SetSecondPassCallback(HandleCreatingCallback2);
14145}
14146
14147
14148THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback)static void TestNoGlobalHandlesOrphaningDueToWeakCallback(); RegisterThreadedTest
register_NoGlobalHandlesOrphaningDueToWeakCallback(TestNoGlobalHandlesOrphaningDueToWeakCallback
, "NoGlobalHandlesOrphaningDueToWeakCallback"); static void TestNoGlobalHandlesOrphaningDueToWeakCallback
(); CcTest register_test_NoGlobalHandlesOrphaningDueToWeakCallback
(TestNoGlobalHandlesOrphaningDueToWeakCallback, "../test/cctest/test-api.cc"
, "NoGlobalHandlesOrphaningDueToWeakCallback", __null, true, true
); static void TestNoGlobalHandlesOrphaningDueToWeakCallback(
)
{
14149 v8::Locker locker(CcTest::isolate());
14150 LocalContext context;
14151 v8::Isolate* isolate = context->GetIsolate();
14152
14153 v8::Persistent<v8::Object> handle1, handle2, handle3;
14154 {
14155 v8::HandleScope scope(isolate);
14156 handle3.Reset(isolate, v8::Object::New(isolate));
14157 handle2.Reset(isolate, v8::Object::New(isolate));
14158 handle1.Reset(isolate, v8::Object::New(isolate));
14159 }
14160 handle2.SetWeak(&handle2, DisposingCallback,
14161 v8::WeakCallbackType::kParameter);
14162 handle3.SetWeak(&handle3, HandleCreatingCallback1,
14163 v8::WeakCallbackType::kParameter);
14164 CcTest::heap()->CollectAllGarbage();
14165 EmptyMessageQueues(isolate);
14166}
14167
14168
14169THREADED_TEST(CheckForCrossContextObjectLiterals)static void TestCheckForCrossContextObjectLiterals(); RegisterThreadedTest
register_CheckForCrossContextObjectLiterals(TestCheckForCrossContextObjectLiterals
, "CheckForCrossContextObjectLiterals"); static void TestCheckForCrossContextObjectLiterals
(); CcTest register_test_CheckForCrossContextObjectLiterals(TestCheckForCrossContextObjectLiterals
, "../test/cctest/test-api.cc", "CheckForCrossContextObjectLiterals"
, __null, true, true); static void TestCheckForCrossContextObjectLiterals
()
{
14170 v8::V8::Initialize();
14171
14172 const int nof = 2;
14173 const char* sources[nof] = {
14174 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }",
14175 "Object()"
14176 };
14177
14178 for (int i = 0; i < nof; i++) {
14179 const char* source = sources[i];
14180 { v8::HandleScope scope(CcTest::isolate());
14181 LocalContext context;
14182 CompileRun(source);
14183 }
14184 { v8::HandleScope scope(CcTest::isolate());
14185 LocalContext context;
14186 CompileRun(source);
14187 }
14188 }
14189}
14190
14191
14192static v8::Local<Value> NestedScope(v8::Local<Context> env) {
14193 v8::EscapableHandleScope inner(env->GetIsolate());
14194 env->Enter();
14195 v8::Local<Value> three = v8_num(3);
14196 v8::Local<Value> value = inner.Escape(three);
14197 env->Exit();
14198 return value;
14199}
14200
14201
14202THREADED_TEST(NestedHandleScopeAndContexts)static void TestNestedHandleScopeAndContexts(); RegisterThreadedTest
register_NestedHandleScopeAndContexts(TestNestedHandleScopeAndContexts
, "NestedHandleScopeAndContexts"); static void TestNestedHandleScopeAndContexts
(); CcTest register_test_NestedHandleScopeAndContexts(TestNestedHandleScopeAndContexts
, "../test/cctest/test-api.cc", "NestedHandleScopeAndContexts"
, __null, true, true); static void TestNestedHandleScopeAndContexts
()
{
14203 v8::Isolate* isolate = CcTest::isolate();
14204 v8::HandleScope outer(isolate);
14205 v8::Local<Context> env = Context::New(isolate);
14206 env->Enter();
14207 v8::Local<Value> value = NestedScope(env);
14208 v8::Local<String> str(value->ToString(env).ToLocalChecked());
14209 CHECK(!str.IsEmpty())do { if ((__builtin_expect(!!(!(!str.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14209, "Check failed: %s.", "!str.IsEmpty()"
); } } while (0)
;
14210 env->Exit();
14211}
14212
14213
14214static bool MatchPointers(void* key1, void* key2) {
14215 return key1 == key2;
14216}
14217
14218
14219struct SymbolInfo {
14220 size_t id;
14221 size_t size;
14222 std::string name;
14223};
14224
14225
14226class SetFunctionEntryHookTest {
14227 public:
14228 SetFunctionEntryHookTest() {
14229 CHECK(instance_ == NULL)do { if ((__builtin_expect(!!(!(instance_ == __null)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14229, "Check failed: %s."
, "instance_ == NULL"); } } while (0)
;
14230 instance_ = this;
14231 }
14232 ~SetFunctionEntryHookTest() {
14233 CHECK(instance_ == this)do { if ((__builtin_expect(!!(!(instance_ == this)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14233, "Check failed: %s.", "instance_ == this"
); } } while (0)
;
14234 instance_ = NULL__null;
14235 }
14236 void Reset() {
14237 symbols_.clear();
14238 symbol_locations_.clear();
14239 invocations_.clear();
14240 }
14241 void RunTest();
14242 void OnJitEvent(const v8::JitCodeEvent* event);
14243 static void JitEvent(const v8::JitCodeEvent* event) {
14244 CHECK(instance_ != NULL)do { if ((__builtin_expect(!!(!(instance_ != __null)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14244, "Check failed: %s."
, "instance_ != NULL"); } } while (0)
;
14245 instance_->OnJitEvent(event);
14246 }
14247
14248 void OnEntryHook(uintptr_t function,
14249 uintptr_t return_addr_location);
14250 static void EntryHook(uintptr_t function,
14251 uintptr_t return_addr_location) {
14252 CHECK(instance_ != NULL)do { if ((__builtin_expect(!!(!(instance_ != __null)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14252, "Check failed: %s."
, "instance_ != NULL"); } } while (0)
;
14253 instance_->OnEntryHook(function, return_addr_location);
14254 }
14255
14256 static void RuntimeCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
14257 CHECK(instance_ != NULL)do { if ((__builtin_expect(!!(!(instance_ != __null)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14257, "Check failed: %s."
, "instance_ != NULL"); } } while (0)
;
14258 args.GetReturnValue().Set(v8_num(42));
14259 }
14260 void RunLoopInNewEnv(v8::Isolate* isolate);
14261
14262 // Records addr as location of symbol.
14263 void InsertSymbolAt(i::Address addr, SymbolInfo* symbol);
14264
14265 // Finds the symbol containing addr
14266 SymbolInfo* FindSymbolForAddr(i::Address addr);
14267 // Returns the number of invocations where the caller name contains
14268 // \p caller_name and the function name contains \p function_name.
14269 int CountInvocations(const char* caller_name,
14270 const char* function_name);
14271
14272 i::Handle<i::JSFunction> foo_func_;
14273 i::Handle<i::JSFunction> bar_func_;
14274
14275 typedef std::map<size_t, SymbolInfo> SymbolMap;
14276 typedef std::map<i::Address, SymbolInfo*> SymbolLocationMap;
14277 typedef std::map<std::pair<SymbolInfo*, SymbolInfo*>, int> InvocationMap;
14278 SymbolMap symbols_;
14279 SymbolLocationMap symbol_locations_;
14280 InvocationMap invocations_;
14281
14282 static SetFunctionEntryHookTest* instance_;
14283};
14284SetFunctionEntryHookTest* SetFunctionEntryHookTest::instance_ = NULL__null;
14285
14286
14287// Returns true if addr is in the range [start, start+len).
14288static bool Overlaps(i::Address start, size_t len, i::Address addr) {
14289 if (start <= addr && start + len > addr)
14290 return true;
14291
14292 return false;
14293}
14294
14295void SetFunctionEntryHookTest::InsertSymbolAt(i::Address addr,
14296 SymbolInfo* symbol) {
14297 // Insert the symbol at the new location.
14298 SymbolLocationMap::iterator it =
14299 symbol_locations_.insert(std::make_pair(addr, symbol)).first;
14300 // Now erase symbols to the left and right that overlap this one.
14301 while (it != symbol_locations_.begin()) {
14302 SymbolLocationMap::iterator left = it;
14303 --left;
14304 if (!Overlaps(left->first, left->second->size, addr))
14305 break;
14306 symbol_locations_.erase(left);
14307 }
14308
14309 // Now erase symbols to the left and right that overlap this one.
14310 while (true) {
14311 SymbolLocationMap::iterator right = it;
14312 ++right;
14313 if (right == symbol_locations_.end())
14314 break;
14315 if (!Overlaps(addr, symbol->size, right->first))
14316 break;
14317 symbol_locations_.erase(right);
14318 }
14319}
14320
14321
14322void SetFunctionEntryHookTest::OnJitEvent(const v8::JitCodeEvent* event) {
14323 switch (event->type) {
14324 case v8::JitCodeEvent::CODE_ADDED: {
14325 CHECK(event->code_start != NULL)do { if ((__builtin_expect(!!(!(event->code_start != __null
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14325, "Check failed: %s."
, "event->code_start != NULL"); } } while (0)
;
14326 CHECK_NE(0, static_cast<int>(event->code_len))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (0), (static_cast
<int>(event->code_len)), "0" " " "!=" " " "static_cast<int>(event->code_len)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14326, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14327 CHECK(event->name.str != NULL)do { if ((__builtin_expect(!!(!(event->name.str != __null)
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14327, "Check failed: %s."
, "event->name.str != NULL"); } } while (0)
;
14328 size_t symbol_id = symbols_.size();
14329
14330 // Record the new symbol.
14331 SymbolInfo& info = symbols_[symbol_id];
14332 info.id = symbol_id;
14333 info.size = event->code_len;
14334 info.name.assign(event->name.str, event->name.str + event->name.len);
14335
14336 // And record it's location.
14337 InsertSymbolAt(reinterpret_cast<i::Address>(event->code_start), &info);
14338 }
14339 break;
14340
14341 case v8::JitCodeEvent::CODE_MOVED: {
14342 // We would like to never see code move that we haven't seen before,
14343 // but the code creation event does not happen until the line endings
14344 // have been calculated (this is so that we can report the line in the
14345 // script at which the function source is found, see
14346 // Compiler::RecordFunctionCompilation) and the line endings
14347 // calculations can cause a GC, which can move the newly created code
14348 // before its existence can be logged.
14349 SymbolLocationMap::iterator it(
14350 symbol_locations_.find(
14351 reinterpret_cast<i::Address>(event->code_start)));
14352 if (it != symbol_locations_.end()) {
14353 // Found a symbol at this location, move it.
14354 SymbolInfo* info = it->second;
14355 symbol_locations_.erase(it);
14356 InsertSymbolAt(reinterpret_cast<i::Address>(event->new_code_start),
14357 info);
14358 }
14359 }
14360 default:
14361 break;
14362 }
14363}
14364
14365void SetFunctionEntryHookTest::OnEntryHook(
14366 uintptr_t function, uintptr_t return_addr_location) {
14367 // Get the function's code object.
14368 i::Code* function_code = i::Code::GetCodeFromTargetAddress(
14369 reinterpret_cast<i::Address>(function));
14370 CHECK(function_code != NULL)do { if ((__builtin_expect(!!(!(function_code != __null)), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 14370, "Check failed: %s."
, "function_code != NULL"); } } while (0)
;
14371
14372 // Then try and look up the caller's code object.
14373 i::Address caller = *reinterpret_cast<i::Address*>(return_addr_location);
14374
14375 // Count the invocation.
14376 SymbolInfo* caller_symbol = FindSymbolForAddr(caller);
14377 SymbolInfo* function_symbol =
14378 FindSymbolForAddr(reinterpret_cast<i::Address>(function));
14379 ++invocations_[std::make_pair(caller_symbol, function_symbol)];
14380
14381 if (!bar_func_.is_null() && function_code == bar_func_->code()) {
14382 // Check that we have a symbol for the "bar" function at the right location.
14383 SymbolLocationMap::iterator it(
14384 symbol_locations_.find(function_code->instruction_start()));
14385 CHECK(it != symbol_locations_.end())do { if ((__builtin_expect(!!(!(it != symbol_locations_.end()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14385, "Check failed: %s."
, "it != symbol_locations_.end()"); } } while (0)
;
14386 }
14387
14388 if (!foo_func_.is_null() && function_code == foo_func_->code()) {
14389 // Check that we have a symbol for "foo" at the right location.
14390 SymbolLocationMap::iterator it(
14391 symbol_locations_.find(function_code->instruction_start()));
14392 CHECK(it != symbol_locations_.end())do { if ((__builtin_expect(!!(!(it != symbol_locations_.end()
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14392, "Check failed: %s."
, "it != symbol_locations_.end()"); } } while (0)
;
14393 }
14394}
14395
14396
14397SymbolInfo* SetFunctionEntryHookTest::FindSymbolForAddr(i::Address addr) {
14398 SymbolLocationMap::iterator it(symbol_locations_.lower_bound(addr));
14399 // Do we have a direct hit on a symbol?
14400 if (it != symbol_locations_.end()) {
14401 if (it->first == addr)
14402 return it->second;
14403 }
14404
14405 // If not a direct hit, it'll have to be the previous symbol.
14406 if (it == symbol_locations_.begin())
14407 return NULL__null;
14408
14409 --it;
14410 size_t offs = addr - it->first;
14411 if (offs < it->second->size)
14412 return it->second;
14413
14414 return NULL__null;
14415}
14416
14417
14418int SetFunctionEntryHookTest::CountInvocations(
14419 const char* caller_name, const char* function_name) {
14420 InvocationMap::iterator it(invocations_.begin());
14421 int invocations = 0;
14422 for (; it != invocations_.end(); ++it) {
14423 SymbolInfo* caller = it->first.first;
14424 SymbolInfo* function = it->first.second;
14425
14426 // Filter out non-matching functions.
14427 if (function_name != NULL__null) {
14428 if (function->name.find(function_name) == std::string::npos)
14429 continue;
14430 }
14431
14432 // Filter out non-matching callers.
14433 if (caller_name != NULL__null) {
14434 if (caller == NULL__null)
14435 continue;
14436 if (caller->name.find(caller_name) == std::string::npos)
14437 continue;
14438 }
14439
14440 // It matches add the invocation count to the tally.
14441 invocations += it->second;
14442 }
14443
14444 return invocations;
14445}
14446
14447
14448void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) {
14449 v8::HandleScope outer(isolate);
14450 v8::Local<Context> env = Context::New(isolate);
14451 env->Enter();
14452
14453 Local<ObjectTemplate> t = ObjectTemplate::New(isolate);
14454 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(isolate, RuntimeCallback));
14455 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
, v8_str("obj"), t->NewInstance(env).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14457, "Check failed: %s."
, "env->Global() ->Set(env, v8_str(\"obj\"), t->NewInstance(env).ToLocalChecked()) .FromJust()"
); } } while (0)
14456 ->Set(env, v8_str("obj"), t->NewInstance(env).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
, v8_str("obj"), t->NewInstance(env).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14457, "Check failed: %s."
, "env->Global() ->Set(env, v8_str(\"obj\"), t->NewInstance(env).ToLocalChecked()) .FromJust()"
); } } while (0)
14457 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
, v8_str("obj"), t->NewInstance(env).ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14457, "Check failed: %s."
, "env->Global() ->Set(env, v8_str(\"obj\"), t->NewInstance(env).ToLocalChecked()) .FromJust()"
); } } while (0)
;
14458
14459 const char* script =
14460 "function bar() {\n"
14461 " var sum = 0;\n"
14462 " for (i = 0; i < 100; ++i)\n"
14463 " sum = foo(i);\n"
14464 " return sum;\n"
14465 "}\n"
14466 "function foo(i) { return i * i; }\n"
14467 "// Invoke on the runtime function.\n"
14468 "obj.asdf()";
14469 CompileRun(script);
14470 bar_func_ = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(
14471 *env->Global()->Get(env, v8_str("bar")).ToLocalChecked()));
14472 CHECK(!bar_func_.is_null())do { if ((__builtin_expect(!!(!(!bar_func_.is_null())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14472, "Check failed: %s."
, "!bar_func_.is_null()"); } } while (0)
;
14473
14474 foo_func_ = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(
14475 *env->Global()->Get(env, v8_str("foo")).ToLocalChecked()));
14476 CHECK(!foo_func_.is_null())do { if ((__builtin_expect(!!(!(!foo_func_.is_null())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14476, "Check failed: %s."
, "!foo_func_.is_null()"); } } while (0)
;
14477
14478 v8::Local<v8::Value> value = CompileRun("bar();");
14479 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14479, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
14480 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9801.0
), (v8::Number::Cast(*value)->Value()), "9801.0" " " "==" " "
"v8::Number::Cast(*value)->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 14480, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
14481
14482 // Test the optimized codegen path.
14483 value = CompileRun("%OptimizeFunctionOnNextCall(foo);"
14484 "bar();");
14485 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14485, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
14486 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9801.0
), (v8::Number::Cast(*value)->Value()), "9801.0" " " "==" " "
"v8::Number::Cast(*value)->Value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 14486, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
14487
14488 env->Exit();
14489}
14490
14491
14492void SetFunctionEntryHookTest::RunTest() {
14493 // Work in a new isolate throughout.
14494 v8::Isolate::CreateParams create_params;
14495 create_params.entry_hook = EntryHook;
14496 create_params.code_event_handler = JitEvent;
14497 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
14498 v8::Isolate* isolate = v8::Isolate::New(create_params);
14499
14500 {
14501 v8::Isolate::Scope scope(isolate);
14502
14503 RunLoopInNewEnv(isolate);
14504
14505 // Check the exepected invocation counts.
14506 CHECK_EQ(2, CountInvocations(NULL, "bar"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CountInvocations
(__null, "bar")), "2" " " "==" " " "CountInvocations(__null, \"bar\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 14506, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14507 CHECK_EQ(200, CountInvocations("bar", "foo"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (200), (
CountInvocations("bar", "foo")), "200" " " "==" " " "CountInvocations(\"bar\", \"foo\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 14507, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14508 CHECK_EQ(200, CountInvocations(NULL, "foo"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (200), (
CountInvocations(__null, "foo")), "200" " " "==" " " "CountInvocations(__null, \"foo\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 14508, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14509
14510 // Verify that we have an entry hook on some specific stubs.
14511 CHECK_NE(0, CountInvocations(NULL, "CEntryStub"))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (0), (CountInvocations
(__null, "CEntryStub")), "0" " " "!=" " " "CountInvocations(__null, \"CEntryStub\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 14511, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14512 CHECK_NE(0, CountInvocations(NULL, "JSEntryStub"))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (0), (CountInvocations
(__null, "JSEntryStub")), "0" " " "!=" " " "CountInvocations(__null, \"JSEntryStub\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 14512, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14513 CHECK_NE(0, CountInvocations(NULL, "JSEntryTrampoline"))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (0), (CountInvocations
(__null, "JSEntryTrampoline")), "0" " " "!=" " " "CountInvocations(__null, \"JSEntryTrampoline\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 14513, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14514 }
14515 isolate->Dispose();
14516
14517 Reset();
14518
14519 // Make sure a second isolate is unaffected by the previous entry hook.
14520 create_params = v8::Isolate::CreateParams();
14521 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
14522 isolate = v8::Isolate::New(create_params);
14523 {
14524 v8::Isolate::Scope scope(isolate);
14525
14526 // Reset the entry count to zero and set the entry hook.
14527 RunLoopInNewEnv(isolate);
14528
14529 // We should record no invocations in this isolate.
14530 CHECK_EQ(0, static_cast<int>(invocations_.size()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (static_cast
<int>(invocations_.size())), "0" " " "==" " " "static_cast<int>(invocations_.size())"
)) { V8_Fatal("../test/cctest/test-api.cc", 14530, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14531 }
14532
14533 isolate->Dispose();
14534}
14535
14536
14537TEST(SetFunctionEntryHook)static void TestSetFunctionEntryHook(); CcTest register_test_SetFunctionEntryHook
(TestSetFunctionEntryHook, "../test/cctest/test-api.cc", "SetFunctionEntryHook"
, __null, true, true); static void TestSetFunctionEntryHook()
{
14538 // FunctionEntryHook does not work well with experimental natives.
14539 // Experimental natives are compiled during snapshot deserialization.
14540 // This test breaks because InstallGetter (function from snapshot that
14541 // only gets called from experimental natives) is compiled with entry hooks.
14542 i::FLAG_allow_natives_syntax = true;
14543 i::FLAG_turbo_inlining = false;
14544 i::FLAG_use_inlining = false;
14545
14546 SetFunctionEntryHookTest test;
14547 test.RunTest();
14548}
14549
14550
14551static i::HashMap* code_map = NULL__null;
14552static i::HashMap* jitcode_line_info = NULL__null;
14553static int saw_bar = 0;
14554static int move_events = 0;
14555
14556
14557static bool FunctionNameIs(const char* expected,
14558 const v8::JitCodeEvent* event) {
14559 // Log lines for functions are of the general form:
14560 // "LazyCompile:<type><function_name>", where the type is one of
14561 // "*", "~" or "".
14562 static const char kPreamble[] = "LazyCompile:";
14563 static size_t kPreambleLen = sizeof(kPreamble) - 1;
14564
14565 if (event->name.len < sizeof(kPreamble) - 1 ||
14566 strncmp(kPreamble, event->name.str, kPreambleLen) != 0) {
14567 return false;
14568 }
14569
14570 const char* tail = event->name.str + kPreambleLen;
14571 size_t tail_len = event->name.len - kPreambleLen;
14572 size_t expected_len = strlen(expected);
14573 if (tail_len > 1 && (*tail == '*' || *tail == '~')) {
14574 --tail_len;
14575 ++tail;
14576 }
14577
14578 // Check for tails like 'bar :1'.
14579 if (tail_len > expected_len + 2 &&
14580 tail[expected_len] == ' ' &&
14581 tail[expected_len + 1] == ':' &&
14582 tail[expected_len + 2] &&
14583 !strncmp(tail, expected, expected_len)) {
14584 return true;
14585 }
14586
14587 if (tail_len != expected_len)
14588 return false;
14589
14590 return strncmp(tail, expected, expected_len) == 0;
14591}
14592
14593
14594static void event_handler(const v8::JitCodeEvent* event) {
14595 CHECK(event != NULL)do { if ((__builtin_expect(!!(!(event != __null)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14595, "Check failed: %s.", "event != NULL"
); } } while (0)
;
14596 CHECK(code_map != NULL)do { if ((__builtin_expect(!!(!(code_map != __null)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14596, "Check failed: %s.", "code_map != NULL"
); } } while (0)
;
14597 CHECK(jitcode_line_info != NULL)do { if ((__builtin_expect(!!(!(jitcode_line_info != __null))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 14597, "Check failed: %s."
, "jitcode_line_info != NULL"); } } while (0)
;
14598
14599 class DummyJitCodeLineInfo {
14600 };
14601
14602 switch (event->type) {
14603 case v8::JitCodeEvent::CODE_ADDED: {
14604 CHECK(event->code_start != NULL)do { if ((__builtin_expect(!!(!(event->code_start != __null
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14604, "Check failed: %s."
, "event->code_start != NULL"); } } while (0)
;
14605 CHECK_NE(0, static_cast<int>(event->code_len))do { if (std::string* _msg = ::v8::base::CheckNEImpl( (0), (static_cast
<int>(event->code_len)), "0" " " "!=" " " "static_cast<int>(event->code_len)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14605, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14606 CHECK(event->name.str != NULL)do { if ((__builtin_expect(!!(!(event->name.str != __null)
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14606, "Check failed: %s."
, "event->name.str != NULL"); } } while (0)
;
14607 i::HashMap::Entry* entry = code_map->LookupOrInsert(
14608 event->code_start, i::ComputePointerHash(event->code_start));
14609 entry->value = reinterpret_cast<void*>(event->code_len);
14610
14611 if (FunctionNameIs("bar", event)) {
14612 ++saw_bar;
14613 }
14614 }
14615 break;
14616
14617 case v8::JitCodeEvent::CODE_MOVED: {
14618 uint32_t hash = i::ComputePointerHash(event->code_start);
14619 // We would like to never see code move that we haven't seen before,
14620 // but the code creation event does not happen until the line endings
14621 // have been calculated (this is so that we can report the line in the
14622 // script at which the function source is found, see
14623 // Compiler::RecordFunctionCompilation) and the line endings
14624 // calculations can cause a GC, which can move the newly created code
14625 // before its existence can be logged.
14626 i::HashMap::Entry* entry = code_map->Lookup(event->code_start, hash);
14627 if (entry != NULL__null) {
14628 ++move_events;
14629
14630 CHECK_EQ(reinterpret_cast<void*>(event->code_len), entry->value)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (reinterpret_cast
<void*>(event->code_len)), (entry->value), "reinterpret_cast<void*>(event->code_len)"
" " "==" " " "entry->value")) { V8_Fatal("../test/cctest/test-api.cc"
, 14630, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
14631 code_map->Remove(event->code_start, hash);
14632
14633 entry = code_map->LookupOrInsert(
14634 event->new_code_start,
14635 i::ComputePointerHash(event->new_code_start));
14636 entry->value = reinterpret_cast<void*>(event->code_len);
14637 }
14638 }
14639 break;
14640
14641 case v8::JitCodeEvent::CODE_REMOVED:
14642 // Object/code removal events are currently not dispatched from the GC.
14643 CHECK(false)do { if ((__builtin_expect(!!(!(false)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 14643, "Check failed: %s.", "false"); } } while (0)
;
14644 break;
14645
14646 // For CODE_START_LINE_INFO_RECORDING event, we will create one
14647 // DummyJitCodeLineInfo data structure pointed by event->user_dat. We
14648 // record it in jitcode_line_info.
14649 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: {
14650 DummyJitCodeLineInfo* line_info = new DummyJitCodeLineInfo();
14651 v8::JitCodeEvent* temp_event = const_cast<v8::JitCodeEvent*>(event);
14652 temp_event->user_data = line_info;
14653 i::HashMap::Entry* entry = jitcode_line_info->LookupOrInsert(
14654 line_info, i::ComputePointerHash(line_info));
14655 entry->value = reinterpret_cast<void*>(line_info);
14656 }
14657 break;
14658 // For these two events, we will check whether the event->user_data
14659 // data structure is created before during CODE_START_LINE_INFO_RECORDING
14660 // event. And delete it in CODE_END_LINE_INFO_RECORDING event handling.
14661 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: {
14662 CHECK(event->user_data != NULL)do { if ((__builtin_expect(!!(!(event->user_data != __null
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14662, "Check failed: %s."
, "event->user_data != NULL"); } } while (0)
;
14663 uint32_t hash = i::ComputePointerHash(event->user_data);
14664 i::HashMap::Entry* entry =
14665 jitcode_line_info->Lookup(event->user_data, hash);
14666 CHECK(entry != NULL)do { if ((__builtin_expect(!!(!(entry != __null)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14666, "Check failed: %s.", "entry != NULL"
); } } while (0)
;
14667 delete reinterpret_cast<DummyJitCodeLineInfo*>(event->user_data);
14668 }
14669 break;
14670
14671 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: {
14672 CHECK(event->user_data != NULL)do { if ((__builtin_expect(!!(!(event->user_data != __null
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14672, "Check failed: %s."
, "event->user_data != NULL"); } } while (0)
;
14673 uint32_t hash = i::ComputePointerHash(event->user_data);
14674 i::HashMap::Entry* entry =
14675 jitcode_line_info->Lookup(event->user_data, hash);
14676 CHECK(entry != NULL)do { if ((__builtin_expect(!!(!(entry != __null)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14676, "Check failed: %s.", "entry != NULL"
); } } while (0)
;
14677 }
14678 break;
14679
14680 default:
14681 // Impossible event.
14682 CHECK(false)do { if ((__builtin_expect(!!(!(false)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 14682, "Check failed: %s.", "false"); } } while (0)
;
14683 break;
14684 }
14685}
14686
14687
14688UNINITIALIZED_TEST(SetJitCodeEventHandler)static void TestSetJitCodeEventHandler(); CcTest register_test_SetJitCodeEventHandler
(TestSetJitCodeEventHandler, "../test/cctest/test-api.cc", "SetJitCodeEventHandler"
, __null, true, false); static void TestSetJitCodeEventHandler
()
{
14689 i::FLAG_stress_compaction = true;
14690 i::FLAG_incremental_marking = false;
14691 if (i::FLAG_never_compact) return;
14692 const char* script =
14693 "function bar() {"
14694 " var sum = 0;"
14695 " for (i = 0; i < 10; ++i)"
14696 " sum = foo(i);"
14697 " return sum;"
14698 "}"
14699 "function foo(i) { return i; };"
14700 "bar();";
14701
14702 // Run this test in a new isolate to make sure we don't
14703 // have remnants of state from other code.
14704 v8::Isolate::CreateParams create_params;
14705 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
14706 v8::Isolate* isolate = v8::Isolate::New(create_params);
14707 isolate->Enter();
14708 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
14709 i::Heap* heap = i_isolate->heap();
14710
14711 // Start with a clean slate.
14712 heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler_Prepare");
14713
14714 {
14715 v8::HandleScope scope(isolate);
14716 i::HashMap code(MatchPointers);
14717 code_map = &code;
14718
14719 i::HashMap lineinfo(MatchPointers);
14720 jitcode_line_info = &lineinfo;
14721
14722 saw_bar = 0;
14723 move_events = 0;
14724
14725 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler);
14726
14727 // Generate new code objects sparsely distributed across several
14728 // different fragmented code-space pages.
14729 const int kIterations = 10;
14730 for (int i = 0; i < kIterations; ++i) {
14731 LocalContext env(isolate);
14732 i::AlwaysAllocateScope always_allocate(i_isolate);
14733 SimulateFullSpace(heap->code_space());
14734 CompileRun(script);
14735
14736 // Keep a strong reference to the code object in the handle scope.
14737 i::Handle<i::Code> bar_code(
14738 i::Handle<i::JSFunction>::cast(
14739 v8::Utils::OpenHandle(*env->Global()
14740 ->Get(env.local(), v8_str("bar"))
14741 .ToLocalChecked()))
14742 ->code());
14743 i::Handle<i::Code> foo_code(
14744 i::Handle<i::JSFunction>::cast(
14745 v8::Utils::OpenHandle(*env->Global()
14746 ->Get(env.local(), v8_str("foo"))
14747 .ToLocalChecked()))
14748 ->code());
14749
14750 // Clear the compilation cache to get more wastage.
14751 reinterpret_cast<i::Isolate*>(isolate)->compilation_cache()->Clear();
14752 }
14753
14754 // Force code movement.
14755 heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler_Move");
14756
14757 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL__null);
14758
14759 CHECK_LE(kIterations, saw_bar)do { if (std::string* _msg = ::v8::base::CheckLEImpl( (kIterations
), (saw_bar), "kIterations" " " "<=" " " "saw_bar")) { V8_Fatal
("../test/cctest/test-api.cc", 14759, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
14760 CHECK_LT(0, move_events)do { if (std::string* _msg = ::v8::base::CheckLTImpl( (0), (move_events
), "0" " " "<" " " "move_events")) { V8_Fatal("../test/cctest/test-api.cc"
, 14760, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
14761
14762 code_map = NULL__null;
14763 jitcode_line_info = NULL__null;
14764 }
14765
14766 isolate->Exit();
14767 isolate->Dispose();
14768
14769 // Do this in a new isolate.
14770 isolate = v8::Isolate::New(create_params);
14771 isolate->Enter();
14772
14773 // Verify that we get callbacks for existing code objects when we
14774 // request enumeration of existing code.
14775 {
14776 v8::HandleScope scope(isolate);
14777 LocalContext env(isolate);
14778 CompileRun(script);
14779
14780 // Now get code through initial iteration.
14781 i::HashMap code(MatchPointers);
14782 code_map = &code;
14783
14784 i::HashMap lineinfo(MatchPointers);
14785 jitcode_line_info = &lineinfo;
14786
14787 isolate->SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting,
14788 event_handler);
14789 isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL__null);
14790
14791 jitcode_line_info = NULL__null;
14792 // We expect that we got some events. Note that if we could get code removal
14793 // notifications, we could compare two collections, one created by listening
14794 // from the time of creation of an isolate, and the other by subscribing
14795 // with EnumExisting.
14796 CHECK_LT(0u, code.occupancy())do { if (std::string* _msg = ::v8::base::CheckLTImpl( (0u), (
code.occupancy()), "0u" " " "<" " " "code.occupancy()")) {
V8_Fatal("../test/cctest/test-api.cc", 14796, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14797
14798 code_map = NULL__null;
14799 }
14800
14801 isolate->Exit();
14802 isolate->Dispose();
14803}
14804
14805
14806THREADED_TEST(ExternalAllocatedMemory)static void TestExternalAllocatedMemory(); RegisterThreadedTest
register_ExternalAllocatedMemory(TestExternalAllocatedMemory
, "ExternalAllocatedMemory"); static void TestExternalAllocatedMemory
(); CcTest register_test_ExternalAllocatedMemory(TestExternalAllocatedMemory
, "../test/cctest/test-api.cc", "ExternalAllocatedMemory", __null
, true, true); static void TestExternalAllocatedMemory()
{
14807 v8::Isolate* isolate = CcTest::isolate();
14808 v8::HandleScope outer(isolate);
14809 v8::Local<Context> env(Context::New(isolate));
14810 CHECK(!env.IsEmpty())do { if ((__builtin_expect(!!(!(!env.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14810, "Check failed: %s.", "!env.IsEmpty()"
); } } while (0)
;
14811 const int64_t kSize = 1024*1024;
14812 int64_t baseline = isolate->AdjustAmountOfExternalAllocatedMemory(0);
14813 CHECK_EQ(baseline + kSize,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (baseline
+ kSize), (isolate->AdjustAmountOfExternalAllocatedMemory
(kSize)), "baseline + kSize" " " "==" " " "isolate->AdjustAmountOfExternalAllocatedMemory(kSize)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14814, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14814 isolate->AdjustAmountOfExternalAllocatedMemory(kSize))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (baseline
+ kSize), (isolate->AdjustAmountOfExternalAllocatedMemory
(kSize)), "baseline + kSize" " " "==" " " "isolate->AdjustAmountOfExternalAllocatedMemory(kSize)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14814, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14815 CHECK_EQ(baseline,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (baseline
), (isolate->AdjustAmountOfExternalAllocatedMemory(-kSize)
), "baseline" " " "==" " " "isolate->AdjustAmountOfExternalAllocatedMemory(-kSize)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14816, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14816 isolate->AdjustAmountOfExternalAllocatedMemory(-kSize))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (baseline
), (isolate->AdjustAmountOfExternalAllocatedMemory(-kSize)
), "baseline" " " "==" " " "isolate->AdjustAmountOfExternalAllocatedMemory(-kSize)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14816, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14817 const int64_t kTriggerGCSize =
14818 v8::internal::Internals::kExternalAllocationLimit + 1;
14819 CHECK_EQ(baseline + kTriggerGCSize,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (baseline
+ kTriggerGCSize), (isolate->AdjustAmountOfExternalAllocatedMemory
(kTriggerGCSize)), "baseline + kTriggerGCSize" " " "==" " " "isolate->AdjustAmountOfExternalAllocatedMemory(kTriggerGCSize)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14820, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14820 isolate->AdjustAmountOfExternalAllocatedMemory(kTriggerGCSize))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (baseline
+ kTriggerGCSize), (isolate->AdjustAmountOfExternalAllocatedMemory
(kTriggerGCSize)), "baseline + kTriggerGCSize" " " "==" " " "isolate->AdjustAmountOfExternalAllocatedMemory(kTriggerGCSize)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14820, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14821 CHECK_EQ(baseline,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (baseline
), (isolate->AdjustAmountOfExternalAllocatedMemory(-kTriggerGCSize
)), "baseline" " " "==" " " "isolate->AdjustAmountOfExternalAllocatedMemory(-kTriggerGCSize)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14822, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14822 isolate->AdjustAmountOfExternalAllocatedMemory(-kTriggerGCSize))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (baseline
), (isolate->AdjustAmountOfExternalAllocatedMemory(-kTriggerGCSize
)), "baseline" " " "==" " " "isolate->AdjustAmountOfExternalAllocatedMemory(-kTriggerGCSize)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14822, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14823}
14824
14825
14826TEST(Regress51719)static void TestRegress51719(); CcTest register_test_Regress51719
(TestRegress51719, "../test/cctest/test-api.cc", "Regress51719"
, __null, true, true); static void TestRegress51719()
{
14827 i::FLAG_incremental_marking = false;
14828 CcTest::InitializeVM();
14829
14830 const int64_t kTriggerGCSize =
14831 v8::internal::Internals::kExternalAllocationLimit + 1;
14832 v8::Isolate* isolate = CcTest::isolate();
14833 isolate->AdjustAmountOfExternalAllocatedMemory(kTriggerGCSize);
14834}
14835
14836
14837// Regression test for issue 54, object templates with internal fields
14838// but no accessors or interceptors did not get their internal field
14839// count set on instances.
14840THREADED_TEST(Regress54)static void TestRegress54(); RegisterThreadedTest register_Regress54
(TestRegress54, "Regress54"); static void TestRegress54(); CcTest
register_test_Regress54(TestRegress54, "../test/cctest/test-api.cc"
, "Regress54", __null, true, true); static void TestRegress54
()
{
14841 LocalContext context;
14842 v8::Isolate* isolate = context->GetIsolate();
14843 v8::HandleScope outer(isolate);
14844 static v8::Persistent<v8::ObjectTemplate> templ;
14845 if (templ.IsEmpty()) {
14846 v8::EscapableHandleScope inner(isolate);
14847 v8::Local<v8::ObjectTemplate> local = v8::ObjectTemplate::New(isolate);
14848 local->SetInternalFieldCount(1);
14849 templ.Reset(isolate, inner.Escape(local));
14850 }
14851 v8::Local<v8::Object> result =
14852 v8::Local<v8::ObjectTemplate>::New(isolate, templ)
14853 ->NewInstance(context.local())
14854 .ToLocalChecked();
14855 CHECK_EQ(1, result->InternalFieldCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (result
->InternalFieldCount()), "1" " " "==" " " "result->InternalFieldCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14855, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14856}
14857
14858
14859// If part of the threaded tests, this test makes ThreadingTest fail
14860// on mac.
14861TEST(CatchStackOverflow)static void TestCatchStackOverflow(); CcTest register_test_CatchStackOverflow
(TestCatchStackOverflow, "../test/cctest/test-api.cc", "CatchStackOverflow"
, __null, true, true); static void TestCatchStackOverflow()
{
14862 LocalContext context;
14863 v8::HandleScope scope(context->GetIsolate());
14864 v8::TryCatch try_catch(context->GetIsolate());
14865 v8::Local<v8::Value> result = CompileRun(
14866 "function f() {"
14867 " return f();"
14868 "}"
14869 ""
14870 "f();");
14871 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14871, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
14872}
14873
14874
14875static void CheckTryCatchSourceInfo(v8::Local<v8::Script> script,
14876 const char* resource_name,
14877 int line_offset) {
14878 v8::HandleScope scope(CcTest::isolate());
14879 v8::TryCatch try_catch(CcTest::isolate());
14880 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
14881 CHECK(script->Run(context).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(context).IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 14881, "Check failed: %s."
, "script->Run(context).IsEmpty()"); } } while (0)
;
14882 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 14882, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
14883 v8::Local<v8::Message> message = try_catch.Message();
14884 CHECK(!message.IsEmpty())do { if ((__builtin_expect(!!(!(!message.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 14884, "Check failed: %s.", "!message.IsEmpty()"
); } } while (0)
;
14885 CHECK_EQ(10 + line_offset, message->GetLineNumber(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10 + line_offset
), (message->GetLineNumber(context).FromJust()), "10 + line_offset"
" " "==" " " "message->GetLineNumber(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14885, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14886 CHECK_EQ(91, message->GetStartPosition())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (91), (
message->GetStartPosition()), "91" " " "==" " " "message->GetStartPosition()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14886, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14887 CHECK_EQ(92, message->GetEndPosition())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (92), (
message->GetEndPosition()), "92" " " "==" " " "message->GetEndPosition()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14887, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14888 CHECK_EQ(2, message->GetStartColumn(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (message
->GetStartColumn(context).FromJust()), "2" " " "==" " " "message->GetStartColumn(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14888, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14889 CHECK_EQ(3, message->GetEndColumn(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (message
->GetEndColumn(context).FromJust()), "3" " " "==" " " "message->GetEndColumn(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14889, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14890 v8::String::Utf8Value line(message->GetSourceLine(context).ToLocalChecked());
14891 CHECK_EQ(0, strcmp(" throw 'nirk';", *line))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(" throw 'nirk';", *line)), "0" " " "==" " " "strcmp(\" throw 'nirk';\", *line)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14891, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14892 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName());
14893 CHECK_EQ(0, strcmp(resource_name, *name))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(resource_name, *name)), "0" " " "==" " " "strcmp(resource_name, *name)"
)) { V8_Fatal("../test/cctest/test-api.cc", 14893, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14894}
14895
14896
14897THREADED_TEST(TryCatchSourceInfo)static void TestTryCatchSourceInfo(); RegisterThreadedTest register_TryCatchSourceInfo
(TestTryCatchSourceInfo, "TryCatchSourceInfo"); static void TestTryCatchSourceInfo
(); CcTest register_test_TryCatchSourceInfo(TestTryCatchSourceInfo
, "../test/cctest/test-api.cc", "TryCatchSourceInfo", __null,
true, true); static void TestTryCatchSourceInfo()
{
14898 LocalContext context;
14899 v8::HandleScope scope(context->GetIsolate());
14900 v8::Local<v8::String> source = v8_str(
14901 "function Foo() {\n"
14902 " return Bar();\n"
14903 "}\n"
14904 "\n"
14905 "function Bar() {\n"
14906 " return Baz();\n"
14907 "}\n"
14908 "\n"
14909 "function Baz() {\n"
14910 " throw 'nirk';\n"
14911 "}\n"
14912 "\n"
14913 "Foo();\n");
14914
14915 const char* resource_name;
14916 v8::Local<v8::Script> script;
14917 resource_name = "test.js";
14918 script = CompileWithOrigin(source, resource_name);
14919 CheckTryCatchSourceInfo(script, resource_name, 0);
14920
14921 resource_name = "test1.js";
14922 v8::ScriptOrigin origin1(v8_str(resource_name));
14923 script =
14924 v8::Script::Compile(context.local(), source, &origin1).ToLocalChecked();
14925 CheckTryCatchSourceInfo(script, resource_name, 0);
14926
14927 resource_name = "test2.js";
14928 v8::ScriptOrigin origin2(v8_str(resource_name),
14929 v8::Integer::New(context->GetIsolate(), 7));
14930 script =
14931 v8::Script::Compile(context.local(), source, &origin2).ToLocalChecked();
14932 CheckTryCatchSourceInfo(script, resource_name, 7);
14933}
14934
14935
14936THREADED_TEST(TryCatchSourceInfoForEOSError)static void TestTryCatchSourceInfoForEOSError(); RegisterThreadedTest
register_TryCatchSourceInfoForEOSError(TestTryCatchSourceInfoForEOSError
, "TryCatchSourceInfoForEOSError"); static void TestTryCatchSourceInfoForEOSError
(); CcTest register_test_TryCatchSourceInfoForEOSError(TestTryCatchSourceInfoForEOSError
, "../test/cctest/test-api.cc", "TryCatchSourceInfoForEOSError"
, __null, true, true); static void TestTryCatchSourceInfoForEOSError
()
{
14937 LocalContext context;
14938 v8::HandleScope scope(context->GetIsolate());
14939 v8::TryCatch try_catch(context->GetIsolate());
14940 CHECK(v8::Script::Compile(context.local(), v8_str("!\n")).IsEmpty())do { if ((__builtin_expect(!!(!(v8::Script::Compile(context.local
(), v8_str("!\n")).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 14940, "Check failed: %s.", "v8::Script::Compile(context.local(), v8_str(\"!\\n\")).IsEmpty()"
); } } while (0)
;
14941 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 14941, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
14942 v8::Local<v8::Message> message = try_catch.Message();
14943 CHECK_EQ(1, message->GetLineNumber(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (message
->GetLineNumber(context.local()).FromJust()), "1" " " "=="
" " "message->GetLineNumber(context.local()).FromJust()")
) { V8_Fatal("../test/cctest/test-api.cc", 14943, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14944 CHECK_EQ(0, message->GetStartColumn(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (message
->GetStartColumn(context.local()).FromJust()), "0" " " "=="
" " "message->GetStartColumn(context.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14944, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14945}
14946
14947
14948THREADED_TEST(CompilationCache)static void TestCompilationCache(); RegisterThreadedTest register_CompilationCache
(TestCompilationCache, "CompilationCache"); static void TestCompilationCache
(); CcTest register_test_CompilationCache(TestCompilationCache
, "../test/cctest/test-api.cc", "CompilationCache", __null, true
, true); static void TestCompilationCache()
{
14949 LocalContext context;
14950 v8::HandleScope scope(context->GetIsolate());
14951 v8::Local<v8::String> source0 = v8_str("1234");
14952 v8::Local<v8::String> source1 = v8_str("1234");
14953 v8::Local<v8::Script> script0 = CompileWithOrigin(source0, "test.js");
14954 v8::Local<v8::Script> script1 = CompileWithOrigin(source1, "test.js");
14955 v8::Local<v8::Script> script2 = v8::Script::Compile(context.local(), source0)
14956 .ToLocalChecked(); // different origin
14957 CHECK_EQ(1234, script0->Run(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script0->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script0->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14960, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14958 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script0->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script0->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14960, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14959 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script0->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script0->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14960, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14960 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script0->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script0->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14960, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14961 CHECK_EQ(1234, script1->Run(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script1->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script1->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14964, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14962 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script1->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script1->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14964, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14963 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script1->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script1->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14964, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14964 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script1->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script1->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14964, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14965 CHECK_EQ(1234, script2->Run(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script2->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script2->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14968, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14966 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script2->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script2->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14968, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14967 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script2->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script2->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14968, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
14968 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1234),
(script2->Run(context.local()) .ToLocalChecked() ->Int32Value
(context.local()) .FromJust()), "1234" " " "==" " " "script2->Run(context.local()) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 14968, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14969}
14970
14971
14972static void FunctionNameCallback(
14973 const v8::FunctionCallbackInfo<v8::Value>& args) {
14974 ApiTestFuzzer::Fuzz();
14975 args.GetReturnValue().Set(v8_num(42));
14976}
14977
14978
14979THREADED_TEST(CallbackFunctionName)static void TestCallbackFunctionName(); RegisterThreadedTest register_CallbackFunctionName
(TestCallbackFunctionName, "CallbackFunctionName"); static void
TestCallbackFunctionName(); CcTest register_test_CallbackFunctionName
(TestCallbackFunctionName, "../test/cctest/test-api.cc", "CallbackFunctionName"
, __null, true, true); static void TestCallbackFunctionName()
{
14980 LocalContext context;
14981 v8::Isolate* isolate = context->GetIsolate();
14982 v8::HandleScope scope(isolate);
14983 Local<ObjectTemplate> t = ObjectTemplate::New(isolate);
14984 t->Set(v8_str("asdf"),
14985 v8::FunctionTemplate::New(isolate, FunctionNameCallback));
14986 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), t->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 14989, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), t->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
14987 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), t->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 14989, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), t->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
14988 t->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), t->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 14989, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), t->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
14989 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), t->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 14989, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), t->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
14990 v8::Local<v8::Value> value = CompileRun("obj.asdf.name");
14991 CHECK(value->IsString())do { if ((__builtin_expect(!!(!(value->IsString())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 14991, "Check failed: %s."
, "value->IsString()"); } } while (0)
;
14992 v8::String::Utf8Value name(value);
14993 CHECK_EQ(0, strcmp("asdf", *name))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("asdf", *name)), "0" " " "==" " " "strcmp(\"asdf\", *name)")
) { V8_Fatal("../test/cctest/test-api.cc", 14993, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
14994}
14995
14996
14997THREADED_TEST(DateAccess)static void TestDateAccess(); RegisterThreadedTest register_DateAccess
(TestDateAccess, "DateAccess"); static void TestDateAccess();
CcTest register_test_DateAccess(TestDateAccess, "../test/cctest/test-api.cc"
, "DateAccess", __null, true, true); static void TestDateAccess
()
{
14998 LocalContext context;
14999 v8::HandleScope scope(context->GetIsolate());
15000 v8::Local<v8::Value> date =
15001 v8::Date::New(context.local(), 1224744689038.0).ToLocalChecked();
15002 CHECK(date->IsDate())do { if ((__builtin_expect(!!(!(date->IsDate())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15002, "Check failed: %s.", "date->IsDate()"
); } } while (0)
;
15003 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1224744689038.0
), (date.As<v8::Date>()->ValueOf()), "1224744689038.0"
" " "==" " " "date.As<v8::Date>()->ValueOf()")) { V8_Fatal
("../test/cctest/test-api.cc", 15003, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15004}
15005
15006
15007void CheckProperties(v8::Isolate* isolate, v8::Local<v8::Value> val,
15008 unsigned elmc, const char* elmv[]) {
15009 v8::Local<v8::Context> context = isolate->GetCurrentContext();
15010 v8::Local<v8::Object> obj = val.As<v8::Object>();
15011 v8::Local<v8::Array> props = obj->GetPropertyNames(context).ToLocalChecked();
15012 CHECK_EQ(elmc, props->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (elmc),
(props->Length()), "elmc" " " "==" " " "props->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 15012, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15013 for (unsigned i = 0; i < elmc; i++) {
15014 v8::String::Utf8Value elm(
15015 props->Get(context, v8::Integer::New(isolate, i)).ToLocalChecked());
15016 CHECK_EQ(0, strcmp(elmv[i], *elm))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(elmv[i], *elm)), "0" " " "==" " " "strcmp(elmv[i], *elm)")) {
V8_Fatal("../test/cctest/test-api.cc", 15016, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15017 }
15018}
15019
15020
15021void CheckOwnProperties(v8::Isolate* isolate, v8::Local<v8::Value> val,
15022 unsigned elmc, const char* elmv[]) {
15023 v8::Local<v8::Context> context = isolate->GetCurrentContext();
15024 v8::Local<v8::Object> obj = val.As<v8::Object>();
15025 v8::Local<v8::Array> props =
15026 obj->GetOwnPropertyNames(context).ToLocalChecked();
15027 CHECK_EQ(elmc, props->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (elmc),
(props->Length()), "elmc" " " "==" " " "props->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 15027, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15028 for (unsigned i = 0; i < elmc; i++) {
15029 v8::String::Utf8Value elm(
15030 props->Get(context, v8::Integer::New(isolate, i)).ToLocalChecked());
15031 CHECK_EQ(0, strcmp(elmv[i], *elm))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(elmv[i], *elm)), "0" " " "==" " " "strcmp(elmv[i], *elm)")) {
V8_Fatal("../test/cctest/test-api.cc", 15031, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15032 }
15033}
15034
15035
15036THREADED_TEST(PropertyEnumeration)static void TestPropertyEnumeration(); RegisterThreadedTest register_PropertyEnumeration
(TestPropertyEnumeration, "PropertyEnumeration"); static void
TestPropertyEnumeration(); CcTest register_test_PropertyEnumeration
(TestPropertyEnumeration, "../test/cctest/test-api.cc", "PropertyEnumeration"
, __null, true, true); static void TestPropertyEnumeration()
{
15037 LocalContext context;
15038 v8::Isolate* isolate = context->GetIsolate();
15039 v8::HandleScope scope(isolate);
15040 v8::Local<v8::Value> obj = CompileRun(
15041 "var result = [];"
15042 "result[0] = {};"
15043 "result[1] = {a: 1, b: 2};"
15044 "result[2] = [1, 2, 3];"
15045 "var proto = {x: 1, y: 2, z: 3};"
15046 "var x = { __proto__: proto, w: 0, z: 1 };"
15047 "result[3] = x;"
15048 "result;");
15049 v8::Local<v8::Array> elms = obj.As<v8::Array>();
15050 CHECK_EQ(4u, elms->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4u), (
elms->Length()), "4u" " " "==" " " "elms->Length()")) {
V8_Fatal("../test/cctest/test-api.cc", 15050, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15051 int elmc0 = 0;
15052 const char** elmv0 = NULL__null;
15053 CheckProperties(
15054 isolate,
15055 elms->Get(context.local(), v8::Integer::New(isolate, 0)).ToLocalChecked(),
15056 elmc0, elmv0);
15057 CheckOwnProperties(
15058 isolate,
15059 elms->Get(context.local(), v8::Integer::New(isolate, 0)).ToLocalChecked(),
15060 elmc0, elmv0);
15061 int elmc1 = 2;
15062 const char* elmv1[] = {"a", "b"};
15063 CheckProperties(
15064 isolate,
15065 elms->Get(context.local(), v8::Integer::New(isolate, 1)).ToLocalChecked(),
15066 elmc1, elmv1);
15067 CheckOwnProperties(
15068 isolate,
15069 elms->Get(context.local(), v8::Integer::New(isolate, 1)).ToLocalChecked(),
15070 elmc1, elmv1);
15071 int elmc2 = 3;
15072 const char* elmv2[] = {"0", "1", "2"};
15073 CheckProperties(
15074 isolate,
15075 elms->Get(context.local(), v8::Integer::New(isolate, 2)).ToLocalChecked(),
15076 elmc2, elmv2);
15077 CheckOwnProperties(
15078 isolate,
15079 elms->Get(context.local(), v8::Integer::New(isolate, 2)).ToLocalChecked(),
15080 elmc2, elmv2);
15081 int elmc3 = 4;
15082 const char* elmv3[] = {"w", "z", "x", "y"};
15083 CheckProperties(
15084 isolate,
15085 elms->Get(context.local(), v8::Integer::New(isolate, 3)).ToLocalChecked(),
15086 elmc3, elmv3);
15087 int elmc4 = 2;
15088 const char* elmv4[] = {"w", "z"};
15089 CheckOwnProperties(
15090 isolate,
15091 elms->Get(context.local(), v8::Integer::New(isolate, 3)).ToLocalChecked(),
15092 elmc4, elmv4);
15093}
15094
15095
15096THREADED_TEST(PropertyEnumeration2)static void TestPropertyEnumeration2(); RegisterThreadedTest register_PropertyEnumeration2
(TestPropertyEnumeration2, "PropertyEnumeration2"); static void
TestPropertyEnumeration2(); CcTest register_test_PropertyEnumeration2
(TestPropertyEnumeration2, "../test/cctest/test-api.cc", "PropertyEnumeration2"
, __null, true, true); static void TestPropertyEnumeration2()
{
15097 LocalContext context;
15098 v8::Isolate* isolate = context->GetIsolate();
15099 v8::HandleScope scope(isolate);
15100 v8::Local<v8::Value> obj = CompileRun(
15101 "var result = [];"
15102 "result[0] = {};"
15103 "result[1] = {a: 1, b: 2};"
15104 "result[2] = [1, 2, 3];"
15105 "var proto = {x: 1, y: 2, z: 3};"
15106 "var x = { __proto__: proto, w: 0, z: 1 };"
15107 "result[3] = x;"
15108 "result;");
15109 v8::Local<v8::Array> elms = obj.As<v8::Array>();
15110 CHECK_EQ(4u, elms->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4u), (
elms->Length()), "4u" " " "==" " " "elms->Length()")) {
V8_Fatal("../test/cctest/test-api.cc", 15110, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15111 int elmc0 = 0;
15112 const char** elmv0 = NULL__null;
15113 CheckProperties(
15114 isolate,
15115 elms->Get(context.local(), v8::Integer::New(isolate, 0)).ToLocalChecked(),
15116 elmc0, elmv0);
15117
15118 v8::Local<v8::Value> val =
15119 elms->Get(context.local(), v8::Integer::New(isolate, 0)).ToLocalChecked();
15120 v8::Local<v8::Array> props =
15121 val.As<v8::Object>()->GetPropertyNames(context.local()).ToLocalChecked();
15122 CHECK_EQ(0u, props->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
props->Length()), "0u" " " "==" " " "props->Length()"))
{ V8_Fatal("../test/cctest/test-api.cc", 15122, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15123 for (uint32_t i = 0; i < props->Length(); i++) {
15124 printf("p[%u]\n", i);
15125 }
15126}
15127
15128
15129THREADED_TEST(AccessChecksReenabledCorrectly)static void TestAccessChecksReenabledCorrectly(); RegisterThreadedTest
register_AccessChecksReenabledCorrectly(TestAccessChecksReenabledCorrectly
, "AccessChecksReenabledCorrectly"); static void TestAccessChecksReenabledCorrectly
(); CcTest register_test_AccessChecksReenabledCorrectly(TestAccessChecksReenabledCorrectly
, "../test/cctest/test-api.cc", "AccessChecksReenabledCorrectly"
, __null, true, true); static void TestAccessChecksReenabledCorrectly
()
{
15130 LocalContext context;
15131 v8::Isolate* isolate = context->GetIsolate();
15132 v8::HandleScope scope(isolate);
15133 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
15134 templ->SetAccessCheckCallback(AccessAlwaysBlocked);
15135 templ->Set(v8_str("a"), v8_str("a"));
15136 // Add more than 8 (see kMaxFastProperties) properties
15137 // so that the constructor will force copying map.
15138 // Cannot sprintf, gcc complains unsafety.
15139 char buf[4];
15140 for (char i = '0'; i <= '9' ; i++) {
15141 buf[0] = i;
15142 for (char j = '0'; j <= '9'; j++) {
15143 buf[1] = j;
15144 for (char k = '0'; k <= '9'; k++) {
15145 buf[2] = k;
15146 buf[3] = 0;
15147 templ->Set(v8_str(buf), v8::Number::New(isolate, k));
15148 }
15149 }
15150 }
15151
15152 Local<v8::Object> instance_1 =
15153 templ->NewInstance(context.local()).ToLocalChecked();
15154 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj_1"), instance_1) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 15156, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj_1\"), instance_1) .FromJust()"
); } } while (0)
15155 ->Set(context.local(), v8_str("obj_1"), instance_1)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj_1"), instance_1) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 15156, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj_1\"), instance_1) .FromJust()"
); } } while (0)
15156 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj_1"), instance_1) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 15156, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj_1\"), instance_1) .FromJust()"
); } } while (0)
;
15157
15158 Local<Value> value_1 = CompileRun("obj_1.a");
15159 CHECK(value_1.IsEmpty())do { if ((__builtin_expect(!!(!(value_1.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15159, "Check failed: %s.", "value_1.IsEmpty()"
); } } while (0)
;
15160
15161 Local<v8::Object> instance_2 =
15162 templ->NewInstance(context.local()).ToLocalChecked();
15163 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj_2"), instance_2) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 15165, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj_2\"), instance_2) .FromJust()"
); } } while (0)
15164 ->Set(context.local(), v8_str("obj_2"), instance_2)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj_2"), instance_2) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 15165, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj_2\"), instance_2) .FromJust()"
); } } while (0)
15165 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj_2"), instance_2) .FromJust())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 15165, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"obj_2\"), instance_2) .FromJust()"
); } } while (0)
;
15166
15167 Local<Value> value_2 = CompileRun("obj_2.a");
15168 CHECK(value_2.IsEmpty())do { if ((__builtin_expect(!!(!(value_2.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15168, "Check failed: %s.", "value_2.IsEmpty()"
); } } while (0)
;
15169}
15170
15171
15172// Tests that ScriptData can be serialized and deserialized.
15173TEST(PreCompileSerialization)static void TestPreCompileSerialization(); CcTest register_test_PreCompileSerialization
(TestPreCompileSerialization, "../test/cctest/test-api.cc", "PreCompileSerialization"
, __null, true, true); static void TestPreCompileSerialization
()
{
15174 v8::V8::Initialize();
15175 LocalContext env;
15176 v8::Isolate* isolate = env->GetIsolate();
15177 HandleScope handle_scope(isolate);
15178
15179 i::FLAG_min_preparse_length = 0;
15180 const char* script = "function foo(a) { return a+1; }";
15181 v8::ScriptCompiler::Source source(v8_str(script));
15182 v8::ScriptCompiler::Compile(env.local(), &source,
15183 v8::ScriptCompiler::kProduceParserCache)
15184 .ToLocalChecked();
15185 // Serialize.
15186 const v8::ScriptCompiler::CachedData* cd = source.GetCachedData();
15187 i::byte* serialized_data = i::NewArray<i::byte>(cd->length);
15188 i::MemCopy(serialized_data, cd->data, cd->length);
15189
15190 // Deserialize.
15191 i::ScriptData* deserialized = new i::ScriptData(serialized_data, cd->length);
15192
15193 // Verify that the original is the same as the deserialized.
15194 CHECK_EQ(cd->length, deserialized->length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (cd->
length), (deserialized->length()), "cd->length" " " "=="
" " "deserialized->length()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15194, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15195 CHECK_EQ(0, memcmp(cd->data, deserialized->data(), cd->length))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (memcmp
(cd->data, deserialized->data(), cd->length)), "0" " "
"==" " " "memcmp(cd->data, deserialized->data(), cd->length)"
)) { V8_Fatal("../test/cctest/test-api.cc", 15195, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15196
15197 delete deserialized;
15198 i::DeleteArray(serialized_data);
15199}
15200
15201
15202// This tests that we do not allow dictionary load/call inline caches
15203// to use functions that have not yet been compiled. The potential
15204// problem of loading a function that has not yet been compiled can
15205// arise because we share code between contexts via the compilation
15206// cache.
15207THREADED_TEST(DictionaryICLoadedFunction)static void TestDictionaryICLoadedFunction(); RegisterThreadedTest
register_DictionaryICLoadedFunction(TestDictionaryICLoadedFunction
, "DictionaryICLoadedFunction"); static void TestDictionaryICLoadedFunction
(); CcTest register_test_DictionaryICLoadedFunction(TestDictionaryICLoadedFunction
, "../test/cctest/test-api.cc", "DictionaryICLoadedFunction",
__null, true, true); static void TestDictionaryICLoadedFunction
()
{
15208 v8::HandleScope scope(CcTest::isolate());
15209 // Test LoadIC.
15210 for (int i = 0; i < 2; i++) {
15211 LocalContext context;
15212 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
15214, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"tmp\"), v8::True(CcTest::isolate())) .FromJust()"
); } } while (0)
15213 ->Set(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
15214, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"tmp\"), v8::True(CcTest::isolate())) .FromJust()"
); } } while (0)
15214 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
15214, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"tmp\"), v8::True(CcTest::isolate())) .FromJust()"
); } } while (0)
;
15215 context->Global()->Delete(context.local(), v8_str("tmp")).FromJust();
15216 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');");
15217 }
15218 // Test CallIC.
15219 for (int i = 0; i < 2; i++) {
15220 LocalContext context;
15221 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
15223, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"tmp\"), v8::True(CcTest::isolate())) .FromJust()"
); } } while (0)
15222 ->Set(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
15223, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"tmp\"), v8::True(CcTest::isolate())) .FromJust()"
); } } while (0)
15223 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("tmp"), v8::True(CcTest::isolate()))
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
15223, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"tmp\"), v8::True(CcTest::isolate())) .FromJust()"
); } } while (0)
;
15224 context->Global()->Delete(context.local(), v8_str("tmp")).FromJust();
15225 CompileRun("for (var j = 0; j < 10; j++) RegExp('')");
15226 }
15227}
15228
15229
15230// Test that cross-context new calls use the context of the callee to
15231// create the new JavaScript object.
15232THREADED_TEST(CrossContextNew)static void TestCrossContextNew(); RegisterThreadedTest register_CrossContextNew
(TestCrossContextNew, "CrossContextNew"); static void TestCrossContextNew
(); CcTest register_test_CrossContextNew(TestCrossContextNew,
"../test/cctest/test-api.cc", "CrossContextNew", __null, true
, true); static void TestCrossContextNew()
{
15233 v8::Isolate* isolate = CcTest::isolate();
15234 v8::HandleScope scope(isolate);
15235 v8::Local<Context> context0 = Context::New(isolate);
15236 v8::Local<Context> context1 = Context::New(isolate);
15237
15238 // Allow cross-domain access.
15239 Local<String> token = v8_str("<security token>");
15240 context0->SetSecurityToken(token);
15241 context1->SetSecurityToken(token);
15242
15243 // Set an 'x' property on the Object prototype and define a
15244 // constructor function in context0.
15245 context0->Enter();
15246 CompileRun("Object.prototype.x = 42; function C() {};");
15247 context0->Exit();
15248
15249 // Call the constructor function from context0 and check that the
15250 // result has the 'x' property.
15251 context1->Enter();
15252 CHECK(context1->Global()do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1, v8_str("other"), context0->Global()) .FromJust(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15254, "Check failed: %s."
, "context1->Global() ->Set(context1, v8_str(\"other\"), context0->Global()) .FromJust()"
); } } while (0)
15253 ->Set(context1, v8_str("other"), context0->Global())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1, v8_str("other"), context0->Global()) .FromJust(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15254, "Check failed: %s."
, "context1->Global() ->Set(context1, v8_str(\"other\"), context0->Global()) .FromJust()"
); } } while (0)
15254 .FromJust())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1, v8_str("other"), context0->Global()) .FromJust(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15254, "Check failed: %s."
, "context1->Global() ->Set(context1, v8_str(\"other\"), context0->Global()) .FromJust()"
); } } while (0)
;
15255 Local<Value> value = CompileRun("var instance = new other.C(); instance.x");
15256 CHECK(value->IsInt32())do { if ((__builtin_expect(!!(!(value->IsInt32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 15256, "Check failed: %s."
, "value->IsInt32()"); } } while (0)
;
15257 CHECK_EQ(42, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context1).FromJust()), "42" " " "==" " "
"value->Int32Value(context1).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15257, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15258 context1->Exit();
15259}
15260
15261
15262// Verify that we can clone an object
15263TEST(ObjectClone)static void TestObjectClone(); CcTest register_test_ObjectClone
(TestObjectClone, "../test/cctest/test-api.cc", "ObjectClone"
, __null, true, true); static void TestObjectClone()
{
15264 LocalContext env;
15265 v8::Isolate* isolate = env->GetIsolate();
15266 v8::HandleScope scope(isolate);
15267
15268 const char* sample =
15269 "var rv = {};" \
15270 "rv.alpha = 'hello';" \
15271 "rv.beta = 123;" \
15272 "rv;";
15273
15274 // Create an object, verify basics.
15275 Local<Value> val = CompileRun(sample);
15276 CHECK(val->IsObject())do { if ((__builtin_expect(!!(!(val->IsObject())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15276, "Check failed: %s.", "val->IsObject()"
); } } while (0)
;
15277 Local<v8::Object> obj = val.As<v8::Object>();
15278 obj->Set(env.local(), v8_str("gamma"), v8_str("cloneme")).FromJust();
15279
15280 CHECK(v8_str("hello")do { if ((__builtin_expect(!!(!(v8_str("hello") ->Equals(env
.local(), obj->Get(env.local(), v8_str("alpha")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15283, "Check failed: %s.", "v8_str(\"hello\") ->Equals(env.local(), obj->Get(env.local(), v8_str(\"alpha\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15281 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8_str("hello") ->Equals(env
.local(), obj->Get(env.local(), v8_str("alpha")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15283, "Check failed: %s.", "v8_str(\"hello\") ->Equals(env.local(), obj->Get(env.local(), v8_str(\"alpha\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15282 obj->Get(env.local(), v8_str("alpha")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("hello") ->Equals(env
.local(), obj->Get(env.local(), v8_str("alpha")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15283, "Check failed: %s.", "v8_str(\"hello\") ->Equals(env.local(), obj->Get(env.local(), v8_str(\"alpha\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15283 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("hello") ->Equals(env
.local(), obj->Get(env.local(), v8_str("alpha")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15283, "Check failed: %s.", "v8_str(\"hello\") ->Equals(env.local(), obj->Get(env.local(), v8_str(\"alpha\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
15284 CHECK(v8::Integer::New(isolate, 123)do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), obj->Get(env.local(), v8_str("beta"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15287, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), obj->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15285 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), obj->Get(env.local(), v8_str("beta"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15287, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), obj->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15286 obj->Get(env.local(), v8_str("beta")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), obj->Get(env.local(), v8_str("beta"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15287, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), obj->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15287 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), obj->Get(env.local(), v8_str("beta"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15287, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), obj->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
15288 CHECK(v8_str("cloneme")do { if ((__builtin_expect(!!(!(v8_str("cloneme") ->Equals
(env.local(), obj->Get(env.local(), v8_str("gamma")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15291, "Check failed: %s.", "v8_str(\"cloneme\") ->Equals(env.local(), obj->Get(env.local(), v8_str(\"gamma\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15289 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8_str("cloneme") ->Equals
(env.local(), obj->Get(env.local(), v8_str("gamma")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15291, "Check failed: %s.", "v8_str(\"cloneme\") ->Equals(env.local(), obj->Get(env.local(), v8_str(\"gamma\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15290 obj->Get(env.local(), v8_str("gamma")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("cloneme") ->Equals
(env.local(), obj->Get(env.local(), v8_str("gamma")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15291, "Check failed: %s.", "v8_str(\"cloneme\") ->Equals(env.local(), obj->Get(env.local(), v8_str(\"gamma\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15291 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("cloneme") ->Equals
(env.local(), obj->Get(env.local(), v8_str("gamma")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15291, "Check failed: %s.", "v8_str(\"cloneme\") ->Equals(env.local(), obj->Get(env.local(), v8_str(\"gamma\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
15292
15293 // Clone it.
15294 Local<v8::Object> clone = obj->Clone();
15295 CHECK(v8_str("hello")do { if ((__builtin_expect(!!(!(v8_str("hello") ->Equals(env
.local(), clone->Get(env.local(), v8_str("alpha")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15298, "Check failed: %s.", "v8_str(\"hello\") ->Equals(env.local(), clone->Get(env.local(), v8_str(\"alpha\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15296 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8_str("hello") ->Equals(env
.local(), clone->Get(env.local(), v8_str("alpha")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15298, "Check failed: %s.", "v8_str(\"hello\") ->Equals(env.local(), clone->Get(env.local(), v8_str(\"alpha\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15297 clone->Get(env.local(), v8_str("alpha")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("hello") ->Equals(env
.local(), clone->Get(env.local(), v8_str("alpha")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15298, "Check failed: %s.", "v8_str(\"hello\") ->Equals(env.local(), clone->Get(env.local(), v8_str(\"alpha\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15298 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("hello") ->Equals(env
.local(), clone->Get(env.local(), v8_str("alpha")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15298, "Check failed: %s.", "v8_str(\"hello\") ->Equals(env.local(), clone->Get(env.local(), v8_str(\"alpha\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
15299 CHECK(v8::Integer::New(isolate, 123)do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), clone->Get(env.local(), v8_str(
"beta")).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15302, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), clone->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15300 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), clone->Get(env.local(), v8_str(
"beta")).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15302, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), clone->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15301 clone->Get(env.local(), v8_str("beta")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), clone->Get(env.local(), v8_str(
"beta")).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15302, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), clone->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15302 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), clone->Get(env.local(), v8_str(
"beta")).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15302, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), clone->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
15303 CHECK(v8_str("cloneme")do { if ((__builtin_expect(!!(!(v8_str("cloneme") ->Equals
(env.local(), clone->Get(env.local(), v8_str("gamma")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15306, "Check failed: %s.", "v8_str(\"cloneme\") ->Equals(env.local(), clone->Get(env.local(), v8_str(\"gamma\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15304 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8_str("cloneme") ->Equals
(env.local(), clone->Get(env.local(), v8_str("gamma")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15306, "Check failed: %s.", "v8_str(\"cloneme\") ->Equals(env.local(), clone->Get(env.local(), v8_str(\"gamma\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15305 clone->Get(env.local(), v8_str("gamma")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("cloneme") ->Equals
(env.local(), clone->Get(env.local(), v8_str("gamma")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15306, "Check failed: %s.", "v8_str(\"cloneme\") ->Equals(env.local(), clone->Get(env.local(), v8_str(\"gamma\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15306 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("cloneme") ->Equals
(env.local(), clone->Get(env.local(), v8_str("gamma")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15306, "Check failed: %s.", "v8_str(\"cloneme\") ->Equals(env.local(), clone->Get(env.local(), v8_str(\"gamma\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
15307
15308 // Set a property on the clone, verify each object.
15309 CHECK(clone->Set(env.local(), v8_str("beta"), v8::Integer::New(isolate, 456))do { if ((__builtin_expect(!!(!(clone->Set(env.local(), v8_str
("beta"), v8::Integer::New(isolate, 456)) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 15310, "Check failed: %s."
, "clone->Set(env.local(), v8_str(\"beta\"), v8::Integer::New(isolate, 456)) .FromJust()"
); } } while (0)
15310 .FromJust())do { if ((__builtin_expect(!!(!(clone->Set(env.local(), v8_str
("beta"), v8::Integer::New(isolate, 456)) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 15310, "Check failed: %s."
, "clone->Set(env.local(), v8_str(\"beta\"), v8::Integer::New(isolate, 456)) .FromJust()"
); } } while (0)
;
15311 CHECK(v8::Integer::New(isolate, 123)do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), obj->Get(env.local(), v8_str("beta"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15314, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), obj->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15312 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), obj->Get(env.local(), v8_str("beta"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15314, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), obj->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15313 obj->Get(env.local(), v8_str("beta")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), obj->Get(env.local(), v8_str("beta"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15314, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), obj->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15314 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 123
) ->Equals(env.local(), obj->Get(env.local(), v8_str("beta"
)).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15314, "Check failed: %s.", "v8::Integer::New(isolate, 123) ->Equals(env.local(), obj->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
15315 CHECK(v8::Integer::New(isolate, 456)do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 456
) ->Equals(env.local(), clone->Get(env.local(), v8_str(
"beta")).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15318, "Check failed: %s.", "v8::Integer::New(isolate, 456) ->Equals(env.local(), clone->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15316 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 456
) ->Equals(env.local(), clone->Get(env.local(), v8_str(
"beta")).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15318, "Check failed: %s.", "v8::Integer::New(isolate, 456) ->Equals(env.local(), clone->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15317 clone->Get(env.local(), v8_str("beta")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 456
) ->Equals(env.local(), clone->Get(env.local(), v8_str(
"beta")).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15318, "Check failed: %s.", "v8::Integer::New(isolate, 456) ->Equals(env.local(), clone->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
15318 .FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 456
) ->Equals(env.local(), clone->Get(env.local(), v8_str(
"beta")).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15318, "Check failed: %s.", "v8::Integer::New(isolate, 456) ->Equals(env.local(), clone->Get(env.local(), v8_str(\"beta\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
15319}
15320
15321
15322class OneByteVectorResource : public v8::String::ExternalOneByteStringResource {
15323 public:
15324 explicit OneByteVectorResource(i::Vector<const char> vector)
15325 : data_(vector) {}
15326 virtual ~OneByteVectorResource() {}
15327 virtual size_t length() const { return data_.length(); }
15328 virtual const char* data() const { return data_.start(); }
15329 private:
15330 i::Vector<const char> data_;
15331};
15332
15333
15334class UC16VectorResource : public v8::String::ExternalStringResource {
15335 public:
15336 explicit UC16VectorResource(i::Vector<const i::uc16> vector)
15337 : data_(vector) {}
15338 virtual ~UC16VectorResource() {}
15339 virtual size_t length() const { return data_.length(); }
15340 virtual const i::uc16* data() const { return data_.start(); }
15341 private:
15342 i::Vector<const i::uc16> data_;
15343};
15344
15345
15346static void MorphAString(i::String* string,
15347 OneByteVectorResource* one_byte_resource,
15348 UC16VectorResource* uc16_resource) {
15349 CHECK(i::StringShape(string).IsExternal())do { if ((__builtin_expect(!!(!(i::StringShape(string).IsExternal
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15349, "Check failed: %s."
, "i::StringShape(string).IsExternal()"); } } while (0)
;
15350 if (string->IsOneByteRepresentation()) {
15351 // Check old map is not internalized or long.
15352 CHECK(string->map() == CcTest::heap()->external_one_byte_string_map())do { if ((__builtin_expect(!!(!(string->map() == CcTest::heap
()->external_one_byte_string_map())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15352, "Check failed: %s.", "string->map() == CcTest::heap()->external_one_byte_string_map()"
); } } while (0)
;
15353 // Morph external string to be TwoByte string.
15354 string->set_map(CcTest::heap()->external_string_map());
15355 i::ExternalTwoByteString* morphed =
15356 i::ExternalTwoByteString::cast(string);
15357 morphed->set_resource(uc16_resource);
15358 } else {
15359 // Check old map is not internalized or long.
15360 CHECK(string->map() == CcTest::heap()->external_string_map())do { if ((__builtin_expect(!!(!(string->map() == CcTest::heap
()->external_string_map())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15360, "Check failed: %s.", "string->map() == CcTest::heap()->external_string_map()"
); } } while (0)
;
15361 // Morph external string to be one-byte string.
15362 string->set_map(CcTest::heap()->external_one_byte_string_map());
15363 i::ExternalOneByteString* morphed = i::ExternalOneByteString::cast(string);
15364 morphed->set_resource(one_byte_resource);
15365 }
15366}
15367
15368
15369// Test that we can still flatten a string if the components it is built up
15370// from have been turned into 16 bit strings in the mean time.
15371THREADED_TEST(MorphCompositeStringTest)static void TestMorphCompositeStringTest(); RegisterThreadedTest
register_MorphCompositeStringTest(TestMorphCompositeStringTest
, "MorphCompositeStringTest"); static void TestMorphCompositeStringTest
(); CcTest register_test_MorphCompositeStringTest(TestMorphCompositeStringTest
, "../test/cctest/test-api.cc", "MorphCompositeStringTest", __null
, true, true); static void TestMorphCompositeStringTest()
{
15372 char utf_buffer[129];
15373 const char* c_string = "Now is the time for all good men"
15374 " to come to the aid of the party";
15375 uint16_t* two_byte_string = AsciiToTwoByteString(c_string);
15376 {
15377 LocalContext env;
15378 i::Factory* factory = CcTest::i_isolate()->factory();
15379 v8::HandleScope scope(env->GetIsolate());
15380 OneByteVectorResource one_byte_resource(
15381 i::Vector<const char>(c_string, i::StrLength(c_string)));
15382 UC16VectorResource uc16_resource(
15383 i::Vector<const uint16_t>(two_byte_string,
15384 i::StrLength(c_string)));
15385
15386 Local<String> lhs(
15387 v8::Utils::ToLocal(factory->NewExternalStringFromOneByte(
15388 &one_byte_resource).ToHandleChecked()));
15389 Local<String> rhs(
15390 v8::Utils::ToLocal(factory->NewExternalStringFromOneByte(
15391 &one_byte_resource).ToHandleChecked()));
15392
15393 CHECK(env->Global()->Set(env.local(), v8_str("lhs"), lhs).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("lhs"), lhs).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15393, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"lhs\"), lhs).FromJust()"
); } } while (0)
;
15394 CHECK(env->Global()->Set(env.local(), v8_str("rhs"), rhs).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("rhs"), rhs).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15394, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"rhs\"), rhs).FromJust()"
); } } while (0)
;
15395
15396 CompileRun(
15397 "var cons = lhs + rhs;"
15398 "var slice = lhs.substring(1, lhs.length - 1);"
15399 "var slice_on_cons = (lhs + rhs).substring(1, lhs.length *2 - 1);");
15400
15401 CHECK(lhs->IsOneByte())do { if ((__builtin_expect(!!(!(lhs->IsOneByte())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 15401, "Check failed: %s."
, "lhs->IsOneByte()"); } } while (0)
;
15402 CHECK(rhs->IsOneByte())do { if ((__builtin_expect(!!(!(rhs->IsOneByte())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 15402, "Check failed: %s."
, "rhs->IsOneByte()"); } } while (0)
;
15403
15404 MorphAString(*v8::Utils::OpenHandle(*lhs), &one_byte_resource,
15405 &uc16_resource);
15406 MorphAString(*v8::Utils::OpenHandle(*rhs), &one_byte_resource,
15407 &uc16_resource);
15408
15409 // This should UTF-8 without flattening, since everything is ASCII.
15410 Local<String> cons =
15411 v8_compile("cons")->Run(env.local()).ToLocalChecked().As<String>();
15412 CHECK_EQ(128, cons->Utf8Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (128), (
cons->Utf8Length()), "128" " " "==" " " "cons->Utf8Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 15412, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15413 int nchars = -1;
15414 CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (129), (
cons->WriteUtf8(utf_buffer, -1, &nchars)), "129" " " "=="
" " "cons->WriteUtf8(utf_buffer, -1, &nchars)")) { V8_Fatal
("../test/cctest/test-api.cc", 15414, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15415 CHECK_EQ(128, nchars)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (128), (
nchars), "128" " " "==" " " "nchars")) { V8_Fatal("../test/cctest/test-api.cc"
, 15415, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15416 CHECK_EQ(0, strcmp(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
( utf_buffer, "Now is the time for all good men to come to the aid of the party"
"Now is the time for all good men to come to the aid of the party"
)), "0" " " "==" " " "strcmp( utf_buffer, \"Now is the time for all good men to come to the aid of the party\" \"Now is the time for all good men to come to the aid of the party\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 15419, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
15417 utf_buffer,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
( utf_buffer, "Now is the time for all good men to come to the aid of the party"
"Now is the time for all good men to come to the aid of the party"
)), "0" " " "==" " " "strcmp( utf_buffer, \"Now is the time for all good men to come to the aid of the party\" \"Now is the time for all good men to come to the aid of the party\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 15419, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
15418 "Now is the time for all good men to come to the aid of the party"do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
( utf_buffer, "Now is the time for all good men to come to the aid of the party"
"Now is the time for all good men to come to the aid of the party"
)), "0" " " "==" " " "strcmp( utf_buffer, \"Now is the time for all good men to come to the aid of the party\" \"Now is the time for all good men to come to the aid of the party\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 15419, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
15419 "Now is the time for all good men to come to the aid of the party"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
( utf_buffer, "Now is the time for all good men to come to the aid of the party"
"Now is the time for all good men to come to the aid of the party"
)), "0" " " "==" " " "strcmp( utf_buffer, \"Now is the time for all good men to come to the aid of the party\" \"Now is the time for all good men to come to the aid of the party\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 15419, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15420
15421 // Now do some stuff to make sure the strings are flattened, etc.
15422 CompileRun(
15423 "/[^a-z]/.test(cons);"
15424 "/[^a-z]/.test(slice);"
15425 "/[^a-z]/.test(slice_on_cons);");
15426 const char* expected_cons =
15427 "Now is the time for all good men to come to the aid of the party"
15428 "Now is the time for all good men to come to the aid of the party";
15429 const char* expected_slice =
15430 "ow is the time for all good men to come to the aid of the part";
15431 const char* expected_slice_on_cons =
15432 "ow is the time for all good men to come to the aid of the party"
15433 "Now is the time for all good men to come to the aid of the part";
15434 CHECK(v8_str(expected_cons)do { if ((__builtin_expect(!!(!(v8_str(expected_cons) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("cons"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15438, "Check failed: %s.", "v8_str(expected_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15435 ->Equals(env.local(), env->Global()do { if ((__builtin_expect(!!(!(v8_str(expected_cons) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("cons"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15438, "Check failed: %s.", "v8_str(expected_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15436 ->Get(env.local(), v8_str("cons"))do { if ((__builtin_expect(!!(!(v8_str(expected_cons) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("cons"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15438, "Check failed: %s.", "v8_str(expected_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15437 .ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str(expected_cons) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("cons"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15438, "Check failed: %s.", "v8_str(expected_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15438 .FromJust())do { if ((__builtin_expect(!!(!(v8_str(expected_cons) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("cons"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15438, "Check failed: %s.", "v8_str(expected_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
15439 CHECK(v8_str(expected_slice)do { if ((__builtin_expect(!!(!(v8_str(expected_slice) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("slice"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15443, "Check failed: %s.", "v8_str(expected_slice) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15440 ->Equals(env.local(), env->Global()do { if ((__builtin_expect(!!(!(v8_str(expected_slice) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("slice"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15443, "Check failed: %s.", "v8_str(expected_slice) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15441 ->Get(env.local(), v8_str("slice"))do { if ((__builtin_expect(!!(!(v8_str(expected_slice) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("slice"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15443, "Check failed: %s.", "v8_str(expected_slice) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15442 .ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str(expected_slice) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("slice"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15443, "Check failed: %s.", "v8_str(expected_slice) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15443 .FromJust())do { if ((__builtin_expect(!!(!(v8_str(expected_slice) ->Equals
(env.local(), env->Global() ->Get(env.local(), v8_str("slice"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15443, "Check failed: %s.", "v8_str(expected_slice) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
15444 CHECK(v8_str(expected_slice_on_cons)do { if ((__builtin_expect(!!(!(v8_str(expected_slice_on_cons
) ->Equals(env.local(), env->Global() ->Get(env.local
(), v8_str("slice_on_cons")) .ToLocalChecked()) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 15449, "Check failed: %s."
, "v8_str(expected_slice_on_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice_on_cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15445 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8_str(expected_slice_on_cons
) ->Equals(env.local(), env->Global() ->Get(env.local
(), v8_str("slice_on_cons")) .ToLocalChecked()) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 15449, "Check failed: %s."
, "v8_str(expected_slice_on_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice_on_cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15446 env->Global()do { if ((__builtin_expect(!!(!(v8_str(expected_slice_on_cons
) ->Equals(env.local(), env->Global() ->Get(env.local
(), v8_str("slice_on_cons")) .ToLocalChecked()) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 15449, "Check failed: %s."
, "v8_str(expected_slice_on_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice_on_cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15447 ->Get(env.local(), v8_str("slice_on_cons"))do { if ((__builtin_expect(!!(!(v8_str(expected_slice_on_cons
) ->Equals(env.local(), env->Global() ->Get(env.local
(), v8_str("slice_on_cons")) .ToLocalChecked()) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 15449, "Check failed: %s."
, "v8_str(expected_slice_on_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice_on_cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15448 .ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str(expected_slice_on_cons
) ->Equals(env.local(), env->Global() ->Get(env.local
(), v8_str("slice_on_cons")) .ToLocalChecked()) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 15449, "Check failed: %s."
, "v8_str(expected_slice_on_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice_on_cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
15449 .FromJust())do { if ((__builtin_expect(!!(!(v8_str(expected_slice_on_cons
) ->Equals(env.local(), env->Global() ->Get(env.local
(), v8_str("slice_on_cons")) .ToLocalChecked()) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 15449, "Check failed: %s."
, "v8_str(expected_slice_on_cons) ->Equals(env.local(), env->Global() ->Get(env.local(), v8_str(\"slice_on_cons\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
15450 }
15451 i::DeleteArray(two_byte_string);
15452}
15453
15454
15455TEST(CompileExternalTwoByteSource)static void TestCompileExternalTwoByteSource(); CcTest register_test_CompileExternalTwoByteSource
(TestCompileExternalTwoByteSource, "../test/cctest/test-api.cc"
, "CompileExternalTwoByteSource", __null, true, true); static
void TestCompileExternalTwoByteSource()
{
15456 LocalContext context;
15457 v8::HandleScope scope(context->GetIsolate());
15458
15459 // This is a very short list of sources, which currently is to check for a
15460 // regression caused by r2703.
15461 const char* one_byte_sources[] = {
15462 "0.5",
15463 "-0.5", // This mainly testes PushBack in the Scanner.
15464 "--0.5", // This mainly testes PushBack in the Scanner.
15465 NULL__null};
15466
15467 // Compile the sources as external two byte strings.
15468 for (int i = 0; one_byte_sources[i] != NULL__null; i++) {
15469 uint16_t* two_byte_string = AsciiToTwoByteString(one_byte_sources[i]);
15470 TestResource* uc16_resource = new TestResource(two_byte_string);
15471 v8::Local<v8::String> source =
15472 v8::String::NewExternalTwoByte(context->GetIsolate(), uc16_resource)
15473 .ToLocalChecked();
15474 v8::Script::Compile(context.local(), source).FromMaybe(Local<Script>());
15475 }
15476}
15477
15478
15479#ifndef V8_INTERPRETED_REGEXP
15480
15481struct RegExpInterruptionData {
15482 v8::base::Atomic32 loop_count;
15483 UC16VectorResource* string_resource;
15484 v8::Persistent<v8::String> string;
15485} regexp_interruption_data;
15486
15487
15488class RegExpInterruptionThread : public v8::base::Thread {
15489 public:
15490 explicit RegExpInterruptionThread(v8::Isolate* isolate)
15491 : Thread(Options("TimeoutThread")), isolate_(isolate) {}
15492
15493 virtual void Run() {
15494 for (v8::base::NoBarrier_Store(&regexp_interruption_data.loop_count, 0);
15495 v8::base::NoBarrier_Load(&regexp_interruption_data.loop_count) < 7;
15496 v8::base::NoBarrier_AtomicIncrement(
15497 &regexp_interruption_data.loop_count, 1)) {
15498 // Wait a bit before requesting GC.
15499 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(50));
15500 reinterpret_cast<i::Isolate*>(isolate_)->stack_guard()->RequestGC();
15501 }
15502 // Wait a bit before terminating.
15503 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(50));
15504 isolate_->TerminateExecution();
15505 }
15506
15507 private:
15508 v8::Isolate* isolate_;
15509};
15510
15511
15512void RunBeforeGC(v8::Isolate* isolate, v8::GCType type,
15513 v8::GCCallbackFlags flags) {
15514 if (v8::base::NoBarrier_Load(&regexp_interruption_data.loop_count) != 2) {
15515 return;
15516 }
15517 v8::HandleScope scope(isolate);
15518 v8::Local<v8::String> string = v8::Local<v8::String>::New(
15519 CcTest::isolate(), regexp_interruption_data.string);
15520 string->MakeExternal(regexp_interruption_data.string_resource);
15521}
15522
15523
15524// Test that RegExp execution can be interrupted. Specifically, we test
15525// * interrupting with GC
15526// * turn the subject string from one-byte internal to two-byte external string
15527// * force termination
15528TEST(RegExpInterruption)static void TestRegExpInterruption(); CcTest register_test_RegExpInterruption
(TestRegExpInterruption, "../test/cctest/test-api.cc", "RegExpInterruption"
, __null, true, true); static void TestRegExpInterruption()
{
15529 LocalContext env;
15530 v8::HandleScope scope(env->GetIsolate());
15531
15532 RegExpInterruptionThread timeout_thread(env->GetIsolate());
15533
15534 env->GetIsolate()->AddGCPrologueCallback(RunBeforeGC);
15535 static const char* one_byte_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
15536 i::uc16* uc16_content = AsciiToTwoByteString(one_byte_content);
15537 v8::Local<v8::String> string = v8_str(one_byte_content);
15538
15539 env->Global()->Set(env.local(), v8_str("a"), string).FromJust();
15540 regexp_interruption_data.string.Reset(env->GetIsolate(), string);
15541 regexp_interruption_data.string_resource = new UC16VectorResource(
15542 i::Vector<const i::uc16>(uc16_content, i::StrLength(one_byte_content)));
15543
15544 v8::TryCatch try_catch(env->GetIsolate());
15545 timeout_thread.Start();
15546
15547 CompileRun("/((a*)*)*b/.exec(a)");
15548 CHECK(try_catch.HasTerminated())do { if ((__builtin_expect(!!(!(try_catch.HasTerminated())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 15548, "Check failed: %s."
, "try_catch.HasTerminated()"); } } while (0)
;
15549
15550 timeout_thread.Join();
15551
15552 regexp_interruption_data.string.Reset();
15553 i::DeleteArray(uc16_content);
15554}
15555
15556#endif // V8_INTERPRETED_REGEXP
15557
15558
15559// Test that we cannot set a property on the global object if there
15560// is a read-only property in the prototype chain.
15561TEST(ReadOnlyPropertyInGlobalProto)static void TestReadOnlyPropertyInGlobalProto(); CcTest register_test_ReadOnlyPropertyInGlobalProto
(TestReadOnlyPropertyInGlobalProto, "../test/cctest/test-api.cc"
, "ReadOnlyPropertyInGlobalProto", __null, true, true); static
void TestReadOnlyPropertyInGlobalProto()
{
15562 v8::Isolate* isolate = CcTest::isolate();
15563 v8::HandleScope scope(isolate);
15564 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
15565 LocalContext context(0, templ);
15566 v8::Local<v8::Object> global = context->Global();
15567 v8::Local<v8::Object> global_proto = v8::Local<v8::Object>::Cast(
15568 global->Get(context.local(), v8_str("__proto__")).ToLocalChecked());
15569 global_proto->DefineOwnProperty(context.local(), v8_str("x"),
15570 v8::Integer::New(isolate, 0), v8::ReadOnly)
15571 .FromJust();
15572 global_proto->DefineOwnProperty(context.local(), v8_str("y"),
15573 v8::Integer::New(isolate, 0), v8::ReadOnly)
15574 .FromJust();
15575 // Check without 'eval' or 'with'.
15576 v8::Local<v8::Value> res =
15577 CompileRun("function f() { x = 42; return x; }; f()");
15578 CHECK(v8::Integer::New(isolate, 0)->Equals(context.local(), res).FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 0)->
Equals(context.local(), res).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15578, "Check failed: %s.", "v8::Integer::New(isolate, 0)->Equals(context.local(), res).FromJust()"
); } } while (0)
;
15579 // Check with 'eval'.
15580 res = CompileRun("function f() { eval('1'); y = 43; return y; }; f()");
15581 CHECK(v8::Integer::New(isolate, 0)->Equals(context.local(), res).FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 0)->
Equals(context.local(), res).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15581, "Check failed: %s.", "v8::Integer::New(isolate, 0)->Equals(context.local(), res).FromJust()"
); } } while (0)
;
15582 // Check with 'with'.
15583 res = CompileRun("function f() { with (this) { y = 44 }; return y; }; f()");
15584 CHECK(v8::Integer::New(isolate, 0)->Equals(context.local(), res).FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 0)->
Equals(context.local(), res).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15584, "Check failed: %s.", "v8::Integer::New(isolate, 0)->Equals(context.local(), res).FromJust()"
); } } while (0)
;
15585}
15586
15587
15588TEST(CreateDataProperty)static void TestCreateDataProperty(); CcTest register_test_CreateDataProperty
(TestCreateDataProperty, "../test/cctest/test-api.cc", "CreateDataProperty"
, __null, true, true); static void TestCreateDataProperty()
{
15589 LocalContext env;
15590 v8::Isolate* isolate = env->GetIsolate();
15591 v8::HandleScope handle_scope(isolate);
15592
15593 CompileRun(
15594 "var a = {};"
15595 "var b = [];"
15596 "Object.defineProperty(a, 'foo', {value: 23});"
15597 "Object.defineProperty(a, 'bar', {value: 23, configurable: true});");
15598
15599 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
15600 env->Global()->Get(env.local(), v8_str("a")).ToLocalChecked());
15601 v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(
15602 env->Global()->Get(env.local(), v8_str("b")).ToLocalChecked());
15603 {
15604 // Can't change a non-configurable properties.
15605 v8::TryCatch try_catch(isolate);
15606 CHECK(!obj->CreateDataProperty(env.local(), v8_str("foo"),do { if ((__builtin_expect(!!(!(!obj->CreateDataProperty(env
.local(), v8_str("foo"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15607, "Check failed: %s."
, "!obj->CreateDataProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15607 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(!obj->CreateDataProperty(env
.local(), v8_str("foo"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15607, "Check failed: %s."
, "!obj->CreateDataProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15608 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15608, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15609 CHECK(obj->CreateDataProperty(env.local(), v8_str("bar"),do { if ((__builtin_expect(!!(!(obj->CreateDataProperty(env
.local(), v8_str("bar"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15610, "Check failed: %s."
, "obj->CreateDataProperty(env.local(), v8_str(\"bar\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15610 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(obj->CreateDataProperty(env
.local(), v8_str("bar"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15610, "Check failed: %s."
, "obj->CreateDataProperty(env.local(), v8_str(\"bar\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15611 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15611, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15612 v8::Local<v8::Value> val =
15613 obj->Get(env.local(), v8_str("bar")).ToLocalChecked();
15614 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15614, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15615 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15615, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15616 }
15617
15618 {
15619 // Set a regular property.
15620 v8::TryCatch try_catch(isolate);
15621 CHECK(obj->CreateDataProperty(env.local(), v8_str("blub"),do { if ((__builtin_expect(!!(!(obj->CreateDataProperty(env
.local(), v8_str("blub"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15622, "Check failed: %s."
, "obj->CreateDataProperty(env.local(), v8_str(\"blub\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15622 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(obj->CreateDataProperty(env
.local(), v8_str("blub"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15622, "Check failed: %s."
, "obj->CreateDataProperty(env.local(), v8_str(\"blub\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15623 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15623, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15624 v8::Local<v8::Value> val =
15625 obj->Get(env.local(), v8_str("blub")).ToLocalChecked();
15626 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15626, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15627 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15627, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15628 }
15629
15630 {
15631 // Set an indexed property.
15632 v8::TryCatch try_catch(isolate);
15633 CHECK(obj->CreateDataProperty(env.local(), v8_str("1"),do { if ((__builtin_expect(!!(!(obj->CreateDataProperty(env
.local(), v8_str("1"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15634, "Check failed: %s."
, "obj->CreateDataProperty(env.local(), v8_str(\"1\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15634 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(obj->CreateDataProperty(env
.local(), v8_str("1"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15634, "Check failed: %s."
, "obj->CreateDataProperty(env.local(), v8_str(\"1\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15635 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15635, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15636 v8::Local<v8::Value> val = obj->Get(env.local(), 1).ToLocalChecked();
15637 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15637, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15638 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15638, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15639 }
15640
15641 {
15642 // Special cases for arrays.
15643 v8::TryCatch try_catch(isolate);
15644 CHECK(!arr->CreateDataProperty(env.local(), v8_str("length"),do { if ((__builtin_expect(!!(!(!arr->CreateDataProperty(env
.local(), v8_str("length"), v8::Integer::New(isolate, 1)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15645, "Check failed: %s."
, "!arr->CreateDataProperty(env.local(), v8_str(\"length\"), v8::Integer::New(isolate, 1)).FromJust()"
); } } while (0)
15645 v8::Integer::New(isolate, 1)).FromJust())do { if ((__builtin_expect(!!(!(!arr->CreateDataProperty(env
.local(), v8_str("length"), v8::Integer::New(isolate, 1)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15645, "Check failed: %s."
, "!arr->CreateDataProperty(env.local(), v8_str(\"length\"), v8::Integer::New(isolate, 1)).FromJust()"
); } } while (0)
;
15646 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15646, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15647 }
15648 {
15649 // Special cases for arrays: index exceeds the array's length
15650 v8::TryCatch try_catch(isolate);
15651 CHECK(arr->CreateDataProperty(env.local(), 1, v8::Integer::New(isolate, 23))do { if ((__builtin_expect(!!(!(arr->CreateDataProperty(env
.local(), 1, v8::Integer::New(isolate, 23)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 15652, "Check failed: %s."
, "arr->CreateDataProperty(env.local(), 1, v8::Integer::New(isolate, 23)) .FromJust()"
); } } while (0)
15652 .FromJust())do { if ((__builtin_expect(!!(!(arr->CreateDataProperty(env
.local(), 1, v8::Integer::New(isolate, 23)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 15652, "Check failed: %s."
, "arr->CreateDataProperty(env.local(), 1, v8::Integer::New(isolate, 23)) .FromJust()"
); } } while (0)
;
15653 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15653, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15654 CHECK_EQ(2U, arr->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
arr->Length()), "2U" " " "==" " " "arr->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 15654, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15655 v8::Local<v8::Value> val = arr->Get(env.local(), 1).ToLocalChecked();
15656 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15656, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15657 CHECK_EQ(23.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23.0),
(val->NumberValue(env.local()).FromJust()), "23.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15657, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15658
15659 // Set an existing entry.
15660 CHECK(arr->CreateDataProperty(env.local(), 0, v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(arr->CreateDataProperty(env
.local(), 0, v8::Integer::New(isolate, 42)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 15661, "Check failed: %s."
, "arr->CreateDataProperty(env.local(), 0, v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
15661 .FromJust())do { if ((__builtin_expect(!!(!(arr->CreateDataProperty(env
.local(), 0, v8::Integer::New(isolate, 42)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 15661, "Check failed: %s."
, "arr->CreateDataProperty(env.local(), 0, v8::Integer::New(isolate, 42)) .FromJust()"
); } } while (0)
;
15662 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15662, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15663 val = arr->Get(env.local(), 0).ToLocalChecked();
15664 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15664, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15665 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15665, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15666 }
15667
15668 CompileRun("Object.freeze(a);");
15669 {
15670 // Can't change non-extensible objects.
15671 v8::TryCatch try_catch(isolate);
15672 CHECK(!obj->CreateDataProperty(env.local(), v8_str("baz"),do { if ((__builtin_expect(!!(!(!obj->CreateDataProperty(env
.local(), v8_str("baz"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15673, "Check failed: %s."
, "!obj->CreateDataProperty(env.local(), v8_str(\"baz\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15673 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(!obj->CreateDataProperty(env
.local(), v8_str("baz"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15673, "Check failed: %s."
, "!obj->CreateDataProperty(env.local(), v8_str(\"baz\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15674 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15674, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15675 }
15676
15677 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
15678 templ->SetAccessCheckCallback(AccessAlwaysBlocked);
15679 v8::Local<v8::Object> access_checked =
15680 templ->NewInstance(env.local()).ToLocalChecked();
15681 {
15682 v8::TryCatch try_catch(isolate);
15683 CHECK(access_checked->CreateDataProperty(env.local(), v8_str("foo"),do { if ((__builtin_expect(!!(!(access_checked->CreateDataProperty
(env.local(), v8_str("foo"), v8::Integer::New(isolate, 42)) .
IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15685
, "Check failed: %s.", "access_checked->CreateDataProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)) .IsNothing()"
); } } while (0)
15684 v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(access_checked->CreateDataProperty
(env.local(), v8_str("foo"), v8::Integer::New(isolate, 42)) .
IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15685
, "Check failed: %s.", "access_checked->CreateDataProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)) .IsNothing()"
); } } while (0)
15685 .IsNothing())do { if ((__builtin_expect(!!(!(access_checked->CreateDataProperty
(env.local(), v8_str("foo"), v8::Integer::New(isolate, 42)) .
IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15685
, "Check failed: %s.", "access_checked->CreateDataProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)) .IsNothing()"
); } } while (0)
;
15686 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 15686, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
15687 }
15688}
15689
15690
15691TEST(DefineOwnProperty)static void TestDefineOwnProperty(); CcTest register_test_DefineOwnProperty
(TestDefineOwnProperty, "../test/cctest/test-api.cc", "DefineOwnProperty"
, __null, true, true); static void TestDefineOwnProperty()
{
15692 LocalContext env;
15693 v8::Isolate* isolate = env->GetIsolate();
15694 v8::HandleScope handle_scope(isolate);
15695
15696 CompileRun(
15697 "var a = {};"
15698 "var b = [];"
15699 "Object.defineProperty(a, 'foo', {value: 23});"
15700 "Object.defineProperty(a, 'bar', {value: 23, configurable: true});");
15701
15702 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
15703 env->Global()->Get(env.local(), v8_str("a")).ToLocalChecked());
15704 v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(
15705 env->Global()->Get(env.local(), v8_str("b")).ToLocalChecked());
15706 {
15707 // Can't change a non-configurable properties.
15708 v8::TryCatch try_catch(isolate);
15709 CHECK(!obj->DefineOwnProperty(env.local(), v8_str("foo"),do { if ((__builtin_expect(!!(!(!obj->DefineOwnProperty(env
.local(), v8_str("foo"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15710, "Check failed: %s."
, "!obj->DefineOwnProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15710 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(!obj->DefineOwnProperty(env
.local(), v8_str("foo"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15710, "Check failed: %s."
, "!obj->DefineOwnProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15711 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15711, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15712 CHECK(obj->DefineOwnProperty(env.local(), v8_str("bar"),do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("bar"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15713, "Check failed: %s."
, "obj->DefineOwnProperty(env.local(), v8_str(\"bar\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15713 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("bar"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15713, "Check failed: %s."
, "obj->DefineOwnProperty(env.local(), v8_str(\"bar\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15714 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15714, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15715 v8::Local<v8::Value> val =
15716 obj->Get(env.local(), v8_str("bar")).ToLocalChecked();
15717 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15717, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15718 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15718, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15719 }
15720
15721 {
15722 // Set a regular property.
15723 v8::TryCatch try_catch(isolate);
15724 CHECK(obj->DefineOwnProperty(env.local(), v8_str("blub"),do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("blub"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15725, "Check failed: %s."
, "obj->DefineOwnProperty(env.local(), v8_str(\"blub\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15725 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("blub"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15725, "Check failed: %s."
, "obj->DefineOwnProperty(env.local(), v8_str(\"blub\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15726 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15726, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15727 v8::Local<v8::Value> val =
15728 obj->Get(env.local(), v8_str("blub")).ToLocalChecked();
15729 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15729, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15730 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15730, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15731 }
15732
15733 {
15734 // Set an indexed property.
15735 v8::TryCatch try_catch(isolate);
15736 CHECK(obj->DefineOwnProperty(env.local(), v8_str("1"),do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("1"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15737, "Check failed: %s."
, "obj->DefineOwnProperty(env.local(), v8_str(\"1\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15737 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("1"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15737, "Check failed: %s."
, "obj->DefineOwnProperty(env.local(), v8_str(\"1\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15738 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15738, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15739 v8::Local<v8::Value> val = obj->Get(env.local(), 1).ToLocalChecked();
15740 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15740, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15741 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15741, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15742 }
15743
15744 {
15745 // Special cases for arrays.
15746 v8::TryCatch try_catch(isolate);
15747 CHECK(!arr->DefineOwnProperty(env.local(), v8_str("length"),do { if ((__builtin_expect(!!(!(!arr->DefineOwnProperty(env
.local(), v8_str("length"), v8::Integer::New(isolate, 1)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15748, "Check failed: %s."
, "!arr->DefineOwnProperty(env.local(), v8_str(\"length\"), v8::Integer::New(isolate, 1)).FromJust()"
); } } while (0)
15748 v8::Integer::New(isolate, 1)).FromJust())do { if ((__builtin_expect(!!(!(!arr->DefineOwnProperty(env
.local(), v8_str("length"), v8::Integer::New(isolate, 1)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15748, "Check failed: %s."
, "!arr->DefineOwnProperty(env.local(), v8_str(\"length\"), v8::Integer::New(isolate, 1)).FromJust()"
); } } while (0)
;
15749 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15749, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15750 }
15751 {
15752 // Special cases for arrays: index exceeds the array's length
15753 v8::TryCatch try_catch(isolate);
15754 CHECK(arr->DefineOwnProperty(env.local(), v8_str("1"),do { if ((__builtin_expect(!!(!(arr->DefineOwnProperty(env
.local(), v8_str("1"), v8::Integer::New(isolate, 23)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15755, "Check failed: %s."
, "arr->DefineOwnProperty(env.local(), v8_str(\"1\"), v8::Integer::New(isolate, 23)).FromJust()"
); } } while (0)
15755 v8::Integer::New(isolate, 23)).FromJust())do { if ((__builtin_expect(!!(!(arr->DefineOwnProperty(env
.local(), v8_str("1"), v8::Integer::New(isolate, 23)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15755, "Check failed: %s."
, "arr->DefineOwnProperty(env.local(), v8_str(\"1\"), v8::Integer::New(isolate, 23)).FromJust()"
); } } while (0)
;
15756 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15756, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15757 CHECK_EQ(2U, arr->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
arr->Length()), "2U" " " "==" " " "arr->Length()")) { V8_Fatal
("../test/cctest/test-api.cc", 15757, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15758 v8::Local<v8::Value> val = arr->Get(env.local(), 1).ToLocalChecked();
15759 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15759, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15760 CHECK_EQ(23.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23.0),
(val->NumberValue(env.local()).FromJust()), "23.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15760, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15761
15762 // Set an existing entry.
15763 CHECK(arr->DefineOwnProperty(env.local(), v8_str("0"),do { if ((__builtin_expect(!!(!(arr->DefineOwnProperty(env
.local(), v8_str("0"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15764, "Check failed: %s."
, "arr->DefineOwnProperty(env.local(), v8_str(\"0\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15764 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(arr->DefineOwnProperty(env
.local(), v8_str("0"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15764, "Check failed: %s."
, "arr->DefineOwnProperty(env.local(), v8_str(\"0\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15765 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15765, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15766 val = arr->Get(env.local(), 0).ToLocalChecked();
15767 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15767, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15768 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15768, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15769 }
15770
15771 {
15772 // Set a non-writable property.
15773 v8::TryCatch try_catch(isolate);
15774 CHECK(obj->DefineOwnProperty(env.local(), v8_str("lala"),do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("lala"), v8::Integer::New(isolate, 42), v8::
ReadOnly).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15776, "Check failed: %s.", "obj->DefineOwnProperty(env.local(), v8_str(\"lala\"), v8::Integer::New(isolate, 42), v8::ReadOnly).FromJust()"
); } } while (0)
15775 v8::Integer::New(isolate, 42),do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("lala"), v8::Integer::New(isolate, 42), v8::
ReadOnly).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15776, "Check failed: %s.", "obj->DefineOwnProperty(env.local(), v8_str(\"lala\"), v8::Integer::New(isolate, 42), v8::ReadOnly).FromJust()"
); } } while (0)
15776 v8::ReadOnly).FromJust())do { if ((__builtin_expect(!!(!(obj->DefineOwnProperty(env
.local(), v8_str("lala"), v8::Integer::New(isolate, 42), v8::
ReadOnly).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 15776, "Check failed: %s.", "obj->DefineOwnProperty(env.local(), v8_str(\"lala\"), v8::Integer::New(isolate, 42), v8::ReadOnly).FromJust()"
); } } while (0)
;
15777 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15777, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15778 v8::Local<v8::Value> val =
15779 obj->Get(env.local(), v8_str("lala")).ToLocalChecked();
15780 CHECK(val->IsNumber())do { if ((__builtin_expect(!!(!(val->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15780, "Check failed: %s.", "val->IsNumber()"
); } } while (0)
;
15781 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42.0),
(val->NumberValue(env.local()).FromJust()), "42.0" " " "=="
" " "val->NumberValue(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15781, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15782 CHECK_EQ(v8::ReadOnly, obj->GetPropertyAttributes(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::ReadOnly
), (obj->GetPropertyAttributes( env.local(), v8_str("lala"
)).FromJust()), "v8::ReadOnly" " " "==" " " "obj->GetPropertyAttributes( env.local(), v8_str(\"lala\")).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 15783, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
15783 env.local(), v8_str("lala")).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::ReadOnly
), (obj->GetPropertyAttributes( env.local(), v8_str("lala"
)).FromJust()), "v8::ReadOnly" " " "==" " " "obj->GetPropertyAttributes( env.local(), v8_str(\"lala\")).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 15783, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15784 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15784, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15785 }
15786
15787 CompileRun("Object.freeze(a);");
15788 {
15789 // Can't change non-extensible objects.
15790 v8::TryCatch try_catch(isolate);
15791 CHECK(!obj->DefineOwnProperty(env.local(), v8_str("baz"),do { if ((__builtin_expect(!!(!(!obj->DefineOwnProperty(env
.local(), v8_str("baz"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15792, "Check failed: %s."
, "!obj->DefineOwnProperty(env.local(), v8_str(\"baz\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
15792 v8::Integer::New(isolate, 42)).FromJust())do { if ((__builtin_expect(!!(!(!obj->DefineOwnProperty(env
.local(), v8_str("baz"), v8::Integer::New(isolate, 42)).FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15792, "Check failed: %s."
, "!obj->DefineOwnProperty(env.local(), v8_str(\"baz\"), v8::Integer::New(isolate, 42)).FromJust()"
); } } while (0)
;
15793 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 15793, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
15794 }
15795
15796 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
15797 templ->SetAccessCheckCallback(AccessAlwaysBlocked);
15798 v8::Local<v8::Object> access_checked =
15799 templ->NewInstance(env.local()).ToLocalChecked();
15800 {
15801 v8::TryCatch try_catch(isolate);
15802 CHECK(access_checked->DefineOwnProperty(env.local(), v8_str("foo"),do { if ((__builtin_expect(!!(!(access_checked->DefineOwnProperty
(env.local(), v8_str("foo"), v8::Integer::New(isolate, 42)) .
IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15804
, "Check failed: %s.", "access_checked->DefineOwnProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)) .IsNothing()"
); } } while (0)
15803 v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(access_checked->DefineOwnProperty
(env.local(), v8_str("foo"), v8::Integer::New(isolate, 42)) .
IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15804
, "Check failed: %s.", "access_checked->DefineOwnProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)) .IsNothing()"
); } } while (0)
15804 .IsNothing())do { if ((__builtin_expect(!!(!(access_checked->DefineOwnProperty
(env.local(), v8_str("foo"), v8::Integer::New(isolate, 42)) .
IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15804
, "Check failed: %s.", "access_checked->DefineOwnProperty(env.local(), v8_str(\"foo\"), v8::Integer::New(isolate, 42)) .IsNothing()"
); } } while (0)
;
15805 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 15805, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
15806 }
15807}
15808
15809
15810THREADED_TEST(GetCurrentContextWhenNotInContext)static void TestGetCurrentContextWhenNotInContext(); RegisterThreadedTest
register_GetCurrentContextWhenNotInContext(TestGetCurrentContextWhenNotInContext
, "GetCurrentContextWhenNotInContext"); static void TestGetCurrentContextWhenNotInContext
(); CcTest register_test_GetCurrentContextWhenNotInContext(TestGetCurrentContextWhenNotInContext
, "../test/cctest/test-api.cc", "GetCurrentContextWhenNotInContext"
, __null, true, true); static void TestGetCurrentContextWhenNotInContext
()
{
15811 i::Isolate* isolate = CcTest::i_isolate();
15812 CHECK(isolate != NULL)do { if ((__builtin_expect(!!(!(isolate != __null)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15812, "Check failed: %s.", "isolate != NULL"
); } } while (0)
;
15813 CHECK(isolate->context() == NULL)do { if ((__builtin_expect(!!(!(isolate->context() == __null
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 15813, "Check failed: %s."
, "isolate->context() == NULL"); } } while (0)
;
15814 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
15815 v8::HandleScope scope(v8_isolate);
15816 // The following should not crash, but return an empty handle.
15817 v8::Local<v8::Context> current = v8_isolate->GetCurrentContext();
15818 CHECK(current.IsEmpty())do { if ((__builtin_expect(!!(!(current.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15818, "Check failed: %s.", "current.IsEmpty()"
); } } while (0)
;
15819}
15820
15821
15822// Check that a variable declaration with no explicit initialization
15823// value does shadow an existing property in the prototype chain.
15824THREADED_TEST(InitGlobalVarInProtoChain)static void TestInitGlobalVarInProtoChain(); RegisterThreadedTest
register_InitGlobalVarInProtoChain(TestInitGlobalVarInProtoChain
, "InitGlobalVarInProtoChain"); static void TestInitGlobalVarInProtoChain
(); CcTest register_test_InitGlobalVarInProtoChain(TestInitGlobalVarInProtoChain
, "../test/cctest/test-api.cc", "InitGlobalVarInProtoChain", __null
, true, true); static void TestInitGlobalVarInProtoChain()
{
15825 LocalContext context;
15826 v8::HandleScope scope(context->GetIsolate());
15827 // Introduce a variable in the prototype chain.
15828 CompileRun("__proto__.x = 42");
15829 v8::Local<v8::Value> result = CompileRun("var x = 43; x");
15830 CHECK(!result->IsUndefined())do { if ((__builtin_expect(!!(!(!result->IsUndefined())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 15830, "Check failed: %s."
, "!result->IsUndefined()"); } } while (0)
;
15831 CHECK_EQ(43, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (43), (
result->Int32Value(context.local()).FromJust()), "43" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15831, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15832}
15833
15834
15835// Regression test for issue 398.
15836// If a function is added to an object, creating a constant function
15837// field, and the result is cloned, replacing the constant function on the
15838// original should not affect the clone.
15839// See http://code.google.com/p/v8/issues/detail?id=398
15840THREADED_TEST(ReplaceConstantFunction)static void TestReplaceConstantFunction(); RegisterThreadedTest
register_ReplaceConstantFunction(TestReplaceConstantFunction
, "ReplaceConstantFunction"); static void TestReplaceConstantFunction
(); CcTest register_test_ReplaceConstantFunction(TestReplaceConstantFunction
, "../test/cctest/test-api.cc", "ReplaceConstantFunction", __null
, true, true); static void TestReplaceConstantFunction()
{
15841 LocalContext context;
15842 v8::Isolate* isolate = context->GetIsolate();
15843 v8::HandleScope scope(isolate);
15844 v8::Local<v8::Object> obj = v8::Object::New(isolate);
15845 v8::Local<v8::FunctionTemplate> func_templ =
15846 v8::FunctionTemplate::New(isolate);
15847 v8::Local<v8::String> foo_string = v8_str("foo");
15848 obj->Set(context.local(), foo_string,
15849 func_templ->GetFunction(context.local()).ToLocalChecked())
15850 .FromJust();
15851 v8::Local<v8::Object> obj_clone = obj->Clone();
15852 obj_clone->Set(context.local(), foo_string, v8_str("Hello")).FromJust();
15853 CHECK(!obj->Get(context.local(), foo_string).ToLocalChecked()->IsUndefined())do { if ((__builtin_expect(!!(!(!obj->Get(context.local(),
foo_string).ToLocalChecked()->IsUndefined())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15853, "Check failed: %s.", "!obj->Get(context.local(), foo_string).ToLocalChecked()->IsUndefined()"
); } } while (0)
;
15854}
15855
15856
15857static void CheckElementValue(i::Isolate* isolate,
15858 int expected,
15859 i::Handle<i::Object> obj,
15860 int offset) {
15861 i::Object* element =
15862 *i::Object::GetElement(isolate, obj, offset).ToHandleChecked();
15863 CHECK_EQ(expected, i::Smi::cast(element)->value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected
), (i::Smi::cast(element)->value()), "expected" " " "==" " "
"i::Smi::cast(element)->value()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15863, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15864}
15865
15866
15867template <class ExternalArrayClass, class ElementType>
15868static void ObjectWithExternalArrayTestHelper(Local<Context> context,
15869 v8::Local<Object> obj,
15870 int element_count,
15871 i::ExternalArrayType array_type,
15872 int64_t low, int64_t high) {
15873 i::Handle<i::JSReceiver> jsobj = v8::Utils::OpenHandle(*obj);
15874 i::Isolate* isolate = jsobj->GetIsolate();
15875 obj->Set(context, v8_str("field"),
15876 v8::Int32::New(reinterpret_cast<v8::Isolate*>(isolate), 1503))
15877 .FromJust();
15878 CHECK(context->Global()->Set(context, v8_str("ext_array"), obj).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context, v8_str("ext_array"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 15878, "Check failed: %s.", "context->Global()->Set(context, v8_str(\"ext_array\"), obj).FromJust()"
); } } while (0)
;
15879 v8::Local<v8::Value> result = CompileRun("ext_array.field");
15880 CHECK_EQ(1503, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1503),
(result->Int32Value(context).FromJust()), "1503" " " "=="
" " "result->Int32Value(context).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15880, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15881 result = CompileRun("ext_array[1]");
15882 CHECK_EQ(1, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (result
->Int32Value(context).FromJust()), "1" " " "==" " " "result->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 15882, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
15883
15884 // Check assigned smis
15885 result = CompileRun("for (var i = 0; i < 8; i++) {"
15886 " ext_array[i] = i;"
15887 "}"
15888 "var sum = 0;"
15889 "for (var i = 0; i < 8; i++) {"
15890 " sum += ext_array[i];"
15891 "}"
15892 "sum;");
15893
15894 CHECK_EQ(28, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (28), (
result->Int32Value(context).FromJust()), "28" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15894, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15895 // Check pass through of assigned smis
15896 result = CompileRun("var sum = 0;"
15897 "for (var i = 0; i < 8; i++) {"
15898 " sum += ext_array[i] = ext_array[i] = -i;"
15899 "}"
15900 "sum;");
15901 CHECK_EQ(-28, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-28), (
result->Int32Value(context).FromJust()), "-28" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15901, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15902
15903
15904 // Check assigned smis in reverse order
15905 result = CompileRun("for (var i = 8; --i >= 0; ) {"
15906 " ext_array[i] = i;"
15907 "}"
15908 "var sum = 0;"
15909 "for (var i = 0; i < 8; i++) {"
15910 " sum += ext_array[i];"
15911 "}"
15912 "sum;");
15913 CHECK_EQ(28, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (28), (
result->Int32Value(context).FromJust()), "28" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15913, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15914
15915 // Check pass through of assigned HeapNumbers
15916 result = CompileRun("var sum = 0;"
15917 "for (var i = 0; i < 16; i+=2) {"
15918 " sum += ext_array[i] = ext_array[i] = (-i * 0.5);"
15919 "}"
15920 "sum;");
15921 CHECK_EQ(-28, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-28), (
result->Int32Value(context).FromJust()), "-28" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15921, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15922
15923 // Check assigned HeapNumbers
15924 result = CompileRun("for (var i = 0; i < 16; i+=2) {"
15925 " ext_array[i] = (i * 0.5);"
15926 "}"
15927 "var sum = 0;"
15928 "for (var i = 0; i < 16; i+=2) {"
15929 " sum += ext_array[i];"
15930 "}"
15931 "sum;");
15932 CHECK_EQ(28, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (28), (
result->Int32Value(context).FromJust()), "28" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15932, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15933
15934 // Check assigned HeapNumbers in reverse order
15935 result = CompileRun("for (var i = 14; i >= 0; i-=2) {"
15936 " ext_array[i] = (i * 0.5);"
15937 "}"
15938 "var sum = 0;"
15939 "for (var i = 0; i < 16; i+=2) {"
15940 " sum += ext_array[i];"
15941 "}"
15942 "sum;");
15943 CHECK_EQ(28, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (28), (
result->Int32Value(context).FromJust()), "28" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15943, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15944
15945 i::ScopedVector<char> test_buf(1024);
15946
15947 // Check legal boundary conditions.
15948 // The repeated loads and stores ensure the ICs are exercised.
15949 const char* boundary_program =
15950 "var res = 0;"
15951 "for (var i = 0; i < 16; i++) {"
15952 " ext_array[i] = %lld;"
15953 " if (i > 8) {"
15954 " res = ext_array[i];"
15955 " }"
15956 "}"
15957 "res;";
15958 i::SNPrintF(test_buf,
15959 boundary_program,
15960 low);
15961 result = CompileRun(test_buf.start());
15962 CHECK_EQ(low, result->IntegerValue(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (low), (
result->IntegerValue(context).FromJust()), "low" " " "==" " "
"result->IntegerValue(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15962, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15963
15964 i::SNPrintF(test_buf,
15965 boundary_program,
15966 high);
15967 result = CompileRun(test_buf.start());
15968 CHECK_EQ(high, result->IntegerValue(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (high),
(result->IntegerValue(context).FromJust()), "high" " " "=="
" " "result->IntegerValue(context).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15968, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15969
15970 // Check misprediction of type in IC.
15971 result = CompileRun("var tmp_array = ext_array;"
15972 "var sum = 0;"
15973 "for (var i = 0; i < 8; i++) {"
15974 " tmp_array[i] = i;"
15975 " sum += tmp_array[i];"
15976 " if (i == 4) {"
15977 " tmp_array = {};"
15978 " }"
15979 "}"
15980 "sum;");
15981 // Force GC to trigger verification.
15982 CcTest::heap()->CollectAllGarbage();
15983 CHECK_EQ(28, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (28), (
result->Int32Value(context).FromJust()), "28" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 15983, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
15984
15985 // Make sure out-of-range loads do not throw.
15986 i::SNPrintF(test_buf,
15987 "var caught_exception = false;"
15988 "try {"
15989 " ext_array[%d];"
15990 "} catch (e) {"
15991 " caught_exception = true;"
15992 "}"
15993 "caught_exception;",
15994 element_count);
15995 result = CompileRun(test_buf.start());
15996 CHECK_EQ(false, result->BooleanValue(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (result->BooleanValue(context).FromJust()), "false" " " "=="
" " "result->BooleanValue(context).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 15996, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
15997
15998 // Make sure out-of-range stores do not throw.
15999 i::SNPrintF(test_buf,
16000 "var caught_exception = false;"
16001 "try {"
16002 " ext_array[%d] = 1;"
16003 "} catch (e) {"
16004 " caught_exception = true;"
16005 "}"
16006 "caught_exception;",
16007 element_count);
16008 result = CompileRun(test_buf.start());
16009 CHECK_EQ(false, result->BooleanValue(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (result->BooleanValue(context).FromJust()), "false" " " "=="
" " "result->BooleanValue(context).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 16009, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
16010
16011 // Check other boundary conditions, values and operations.
16012 result = CompileRun("for (var i = 0; i < 8; i++) {"
16013 " ext_array[7] = undefined;"
16014 "}"
16015 "ext_array[7];");
16016 CHECK_EQ(0, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (result
->Int32Value(context).FromJust()), "0" " " "==" " " "result->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16016, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16017 if (array_type == i::kExternalFloat64Array ||
16018 array_type == i::kExternalFloat32Array) {
16019 CHECK(std::isnan(do { if ((__builtin_expect(!!(!(std::isnan( i::Object::GetElement
(isolate, jsobj, 7).ToHandleChecked()->Number()))), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 16020, "Check failed: %s."
, "std::isnan( i::Object::GetElement(isolate, jsobj, 7).ToHandleChecked()->Number())"
); } } while (0)
16020 i::Object::GetElement(isolate, jsobj, 7).ToHandleChecked()->Number()))do { if ((__builtin_expect(!!(!(std::isnan( i::Object::GetElement
(isolate, jsobj, 7).ToHandleChecked()->Number()))), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 16020, "Check failed: %s."
, "std::isnan( i::Object::GetElement(isolate, jsobj, 7).ToHandleChecked()->Number())"
); } } while (0)
;
16021 } else {
16022 CheckElementValue(isolate, 0, jsobj, 7);
16023 }
16024
16025 result = CompileRun("for (var i = 0; i < 8; i++) {"
16026 " ext_array[6] = '2.3';"
16027 "}"
16028 "ext_array[6];");
16029 CHECK_EQ(2, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (result
->Int32Value(context).FromJust()), "2" " " "==" " " "result->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16029, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16030 CHECK_EQ(2,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>( i::Object::GetElement( isolate, jsobj, 6).ToHandleChecked
()->Number())), "2" " " "==" " " "static_cast<int>( i::Object::GetElement( isolate, jsobj, 6).ToHandleChecked()->Number())"
)) { V8_Fatal("../test/cctest/test-api.cc", 16033, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16031 static_cast<int>(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>( i::Object::GetElement( isolate, jsobj, 6).ToHandleChecked
()->Number())), "2" " " "==" " " "static_cast<int>( i::Object::GetElement( isolate, jsobj, 6).ToHandleChecked()->Number())"
)) { V8_Fatal("../test/cctest/test-api.cc", 16033, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16032 i::Object::GetElement(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>( i::Object::GetElement( isolate, jsobj, 6).ToHandleChecked
()->Number())), "2" " " "==" " " "static_cast<int>( i::Object::GetElement( isolate, jsobj, 6).ToHandleChecked()->Number())"
)) { V8_Fatal("../test/cctest/test-api.cc", 16033, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16033 isolate, jsobj, 6).ToHandleChecked()->Number()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>( i::Object::GetElement( isolate, jsobj, 6).ToHandleChecked
()->Number())), "2" " " "==" " " "static_cast<int>( i::Object::GetElement( isolate, jsobj, 6).ToHandleChecked()->Number())"
)) { V8_Fatal("../test/cctest/test-api.cc", 16033, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16034
16035 if (array_type != i::kExternalFloat32Array &&
16036 array_type != i::kExternalFloat64Array) {
16037 // Though the specification doesn't state it, be explicit about
16038 // converting NaNs and +/-Infinity to zero.
16039 result = CompileRun("for (var i = 0; i < 8; i++) {"
16040 " ext_array[i] = 5;"
16041 "}"
16042 "for (var i = 0; i < 8; i++) {"
16043 " ext_array[i] = NaN;"
16044 "}"
16045 "ext_array[5];");
16046 CHECK_EQ(0, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (result
->Int32Value(context).FromJust()), "0" " " "==" " " "result->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16046, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16047 CheckElementValue(isolate, 0, jsobj, 5);
16048
16049 result = CompileRun("for (var i = 0; i < 8; i++) {"
16050 " ext_array[i] = 5;"
16051 "}"
16052 "for (var i = 0; i < 8; i++) {"
16053 " ext_array[i] = Infinity;"
16054 "}"
16055 "ext_array[5];");
16056 int expected_value =
16057 (array_type == i::kExternalUint8ClampedArray) ? 255 : 0;
16058 CHECK_EQ(expected_value, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected_value
), (result->Int32Value(context).FromJust()), "expected_value"
" " "==" " " "result->Int32Value(context).FromJust()")) {
V8_Fatal("../test/cctest/test-api.cc", 16058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16059 CheckElementValue(isolate, expected_value, jsobj, 5);
16060
16061 result = CompileRun("for (var i = 0; i < 8; i++) {"
16062 " ext_array[i] = 5;"
16063 "}"
16064 "for (var i = 0; i < 8; i++) {"
16065 " ext_array[i] = -Infinity;"
16066 "}"
16067 "ext_array[5];");
16068 CHECK_EQ(0, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (result
->Int32Value(context).FromJust()), "0" " " "==" " " "result->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16068, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16069 CheckElementValue(isolate, 0, jsobj, 5);
16070
16071 // Check truncation behavior of integral arrays.
16072 const char* unsigned_data =
16073 "var source_data = [0.6, 10.6];"
16074 "var expected_results = [0, 10];";
16075 const char* signed_data =
16076 "var source_data = [0.6, 10.6, -0.6, -10.6];"
16077 "var expected_results = [0, 10, 0, -10];";
16078 const char* pixel_data =
16079 "var source_data = [0.6, 10.6];"
16080 "var expected_results = [1, 11];";
16081 bool is_unsigned = (array_type == i::kExternalUint8Array ||
16082 array_type == i::kExternalUint16Array ||
16083 array_type == i::kExternalUint32Array);
16084 bool is_pixel_data = array_type == i::kExternalUint8ClampedArray;
16085
16086 i::SNPrintF(test_buf,
16087 "%s"
16088 "var all_passed = true;"
16089 "for (var i = 0; i < source_data.length; i++) {"
16090 " for (var j = 0; j < 8; j++) {"
16091 " ext_array[j] = source_data[i];"
16092 " }"
16093 " all_passed = all_passed &&"
16094 " (ext_array[5] == expected_results[i]);"
16095 "}"
16096 "all_passed;",
16097 (is_unsigned ?
16098 unsigned_data :
16099 (is_pixel_data ? pixel_data : signed_data)));
16100 result = CompileRun(test_buf.start());
16101 CHECK_EQ(true, result->BooleanValue(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (true),
(result->BooleanValue(context).FromJust()), "true" " " "=="
" " "result->BooleanValue(context).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 16101, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
16102 }
16103
16104 i::Handle<ExternalArrayClass> array(ExternalArrayClass::cast(
16105 i::Handle<i::JSObject>::cast(jsobj)->elements()));
16106 for (int i = 0; i < element_count; i++) {
16107 array->set(i, static_cast<ElementType>(i));
16108 }
16109
16110 // Test complex assignments
16111 result = CompileRun("function ee_op_test_complex_func(sum) {"
16112 " for (var i = 0; i < 40; ++i) {"
16113 " sum += (ext_array[i] += 1);"
16114 " sum += (ext_array[i] -= 1);"
16115 " } "
16116 " return sum;"
16117 "}"
16118 "sum=0;"
16119 "for (var i=0;i<10000;++i) {"
16120 " sum=ee_op_test_complex_func(sum);"
16121 "}"
16122 "sum;");
16123 CHECK_EQ(16000000, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16000000
), (result->Int32Value(context).FromJust()), "16000000" " "
"==" " " "result->Int32Value(context).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 16123, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
16124
16125 // Test count operations
16126 result = CompileRun("function ee_op_test_count_func(sum) {"
16127 " for (var i = 0; i < 40; ++i) {"
16128 " sum += (++ext_array[i]);"
16129 " sum += (--ext_array[i]);"
16130 " } "
16131 " return sum;"
16132 "}"
16133 "sum=0;"
16134 "for (var i=0;i<10000;++i) {"
16135 " sum=ee_op_test_count_func(sum);"
16136 "}"
16137 "sum;");
16138 CHECK_EQ(16000000, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (16000000
), (result->Int32Value(context).FromJust()), "16000000" " "
"==" " " "result->Int32Value(context).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 16138, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
16139
16140 result = CompileRun("ext_array[3] = 33;"
16141 "delete ext_array[3];"
16142 "ext_array[3];");
16143 CHECK_EQ(33, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (33), (
result->Int32Value(context).FromJust()), "33" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 16143, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16144
16145 result = CompileRun("ext_array[0] = 10; ext_array[1] = 11;"
16146 "ext_array[2] = 12; ext_array[3] = 13;"
16147 "ext_array.__defineGetter__('2',"
16148 "function() { return 120; });"
16149 "ext_array[2];");
16150 CHECK_EQ(12, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
result->Int32Value(context).FromJust()), "12" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 16150, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16151
16152 result = CompileRun("var js_array = new Array(40);"
16153 "js_array[0] = 77;"
16154 "js_array;");
16155 CHECK_EQ(77, v8::Object::Cast(*result)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16159, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16156 ->Get(context, v8_str("0"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16159, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16157 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16159, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16158 ->Int32Value(context)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16159, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16159 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16159, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16160
16161 result = CompileRun("ext_array[1] = 23;"
16162 "ext_array.__proto__ = [];"
16163 "js_array.__proto__ = ext_array;"
16164 "js_array.concat(ext_array);");
16165 CHECK_EQ(77, v8::Object::Cast(*result)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16169, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16166 ->Get(context, v8_str("0"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16169, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16167 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16169, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16168 ->Int32Value(context)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16169, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16169 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (77), (
v8::Object::Cast(*result) ->Get(context, v8_str("0")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "77" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"0\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16169, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16170 CHECK_EQ(23, v8::Object::Cast(*result)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
v8::Object::Cast(*result) ->Get(context, v8_str("1")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "23" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"1\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16174, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16171 ->Get(context, v8_str("1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
v8::Object::Cast(*result) ->Get(context, v8_str("1")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "23" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"1\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16174, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16172 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
v8::Object::Cast(*result) ->Get(context, v8_str("1")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "23" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"1\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16174, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16173 ->Int32Value(context)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
v8::Object::Cast(*result) ->Get(context, v8_str("1")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "23" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"1\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16174, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16174 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
v8::Object::Cast(*result) ->Get(context, v8_str("1")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "23" " " "==" " " "v8::Object::Cast(*result) ->Get(context, v8_str(\"1\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16174, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16175
16176 result = CompileRun("ext_array[1] = 23;");
16177 CHECK_EQ(23, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
result->Int32Value(context).FromJust()), "23" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 16177, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16178}
16179
16180
16181template <class FixedTypedArrayClass, i::ElementsKind elements_kind,
16182 class ElementType>
16183static void FixedTypedArrayTestHelper(i::ExternalArrayType array_type,
16184 ElementType low, ElementType high) {
16185 i::FLAG_allow_natives_syntax = true;
16186 LocalContext context;
16187 i::Isolate* isolate = CcTest::i_isolate();
16188 i::Factory* factory = isolate->factory();
16189 v8::HandleScope scope(context->GetIsolate());
16190 const int kElementCount = 260;
16191 i::Handle<i::JSTypedArray> jsobj =
16192 factory->NewJSTypedArray(elements_kind, kElementCount);
16193 i::Handle<FixedTypedArrayClass> fixed_array(
16194 FixedTypedArrayClass::cast(jsobj->elements()));
16195 CHECK_EQ(FixedTypedArrayClass::kInstanceType,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (FixedTypedArrayClass
::kInstanceType), (fixed_array->map()->instance_type())
, "FixedTypedArrayClass::kInstanceType" " " "==" " " "fixed_array->map()->instance_type()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16196, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16196 fixed_array->map()->instance_type())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (FixedTypedArrayClass
::kInstanceType), (fixed_array->map()->instance_type())
, "FixedTypedArrayClass::kInstanceType" " " "==" " " "fixed_array->map()->instance_type()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16196, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16197 CHECK_EQ(kElementCount, fixed_array->length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kElementCount
), (fixed_array->length()), "kElementCount" " " "==" " " "fixed_array->length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16197, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16198 CcTest::heap()->CollectAllGarbage();
16199 for (int i = 0; i < kElementCount; i++) {
16200 fixed_array->set(i, static_cast<ElementType>(i));
16201 }
16202 // Force GC to trigger verification.
16203 CcTest::heap()->CollectAllGarbage();
16204 for (int i = 0; i < kElementCount; i++) {
16205 CHECK_EQ(static_cast<int64_t>(static_cast<ElementType>(i)),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(static_cast<ElementType>(i))), (static_cast
<int64_t>(fixed_array->get_scalar(i))), "static_cast<int64_t>(static_cast<ElementType>(i))"
" " "==" " " "static_cast<int64_t>(fixed_array->get_scalar(i))"
)) { V8_Fatal("../test/cctest/test-api.cc", 16206, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
16206 static_cast<int64_t>(fixed_array->get_scalar(i)))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int64_t>(static_cast<ElementType>(i))), (static_cast
<int64_t>(fixed_array->get_scalar(i))), "static_cast<int64_t>(static_cast<ElementType>(i))"
" " "==" " " "static_cast<int64_t>(fixed_array->get_scalar(i))"
)) { V8_Fatal("../test/cctest/test-api.cc", 16206, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16207 }
16208 v8::Local<v8::Object> obj = v8::Utils::ToLocal(jsobj);
16209
16210 ObjectWithExternalArrayTestHelper<FixedTypedArrayClass, ElementType>(
16211 context.local(), obj, kElementCount, array_type,
16212 static_cast<int64_t>(low),
16213 static_cast<int64_t>(high));
16214}
16215
16216
16217THREADED_TEST(FixedUint8Array)static void TestFixedUint8Array(); RegisterThreadedTest register_FixedUint8Array
(TestFixedUint8Array, "FixedUint8Array"); static void TestFixedUint8Array
(); CcTest register_test_FixedUint8Array(TestFixedUint8Array,
"../test/cctest/test-api.cc", "FixedUint8Array", __null, true
, true); static void TestFixedUint8Array()
{
16218 FixedTypedArrayTestHelper<i::FixedUint8Array, i::UINT8_ELEMENTS, uint8_t>(
16219 i::kExternalUint8Array, 0x0, 0xFF);
16220}
16221
16222
16223THREADED_TEST(FixedUint8ClampedArray)static void TestFixedUint8ClampedArray(); RegisterThreadedTest
register_FixedUint8ClampedArray(TestFixedUint8ClampedArray, "FixedUint8ClampedArray"
); static void TestFixedUint8ClampedArray(); CcTest register_test_FixedUint8ClampedArray
(TestFixedUint8ClampedArray, "../test/cctest/test-api.cc", "FixedUint8ClampedArray"
, __null, true, true); static void TestFixedUint8ClampedArray
()
{
16224 FixedTypedArrayTestHelper<i::FixedUint8ClampedArray,
16225 i::UINT8_CLAMPED_ELEMENTS, uint8_t>(
16226 i::kExternalUint8ClampedArray, 0x0, 0xFF);
16227}
16228
16229
16230THREADED_TEST(FixedInt8Array)static void TestFixedInt8Array(); RegisterThreadedTest register_FixedInt8Array
(TestFixedInt8Array, "FixedInt8Array"); static void TestFixedInt8Array
(); CcTest register_test_FixedInt8Array(TestFixedInt8Array, "../test/cctest/test-api.cc"
, "FixedInt8Array", __null, true, true); static void TestFixedInt8Array
()
{
16231 FixedTypedArrayTestHelper<i::FixedInt8Array, i::INT8_ELEMENTS, int8_t>(
16232 i::kExternalInt8Array, -0x80, 0x7F);
16233}
16234
16235
16236THREADED_TEST(FixedUint16Array)static void TestFixedUint16Array(); RegisterThreadedTest register_FixedUint16Array
(TestFixedUint16Array, "FixedUint16Array"); static void TestFixedUint16Array
(); CcTest register_test_FixedUint16Array(TestFixedUint16Array
, "../test/cctest/test-api.cc", "FixedUint16Array", __null, true
, true); static void TestFixedUint16Array()
{
16237 FixedTypedArrayTestHelper<i::FixedUint16Array, i::UINT16_ELEMENTS, uint16_t>(
16238 i::kExternalUint16Array, 0x0, 0xFFFF);
16239}
16240
16241
16242THREADED_TEST(FixedInt16Array)static void TestFixedInt16Array(); RegisterThreadedTest register_FixedInt16Array
(TestFixedInt16Array, "FixedInt16Array"); static void TestFixedInt16Array
(); CcTest register_test_FixedInt16Array(TestFixedInt16Array,
"../test/cctest/test-api.cc", "FixedInt16Array", __null, true
, true); static void TestFixedInt16Array()
{
16243 FixedTypedArrayTestHelper<i::FixedInt16Array, i::INT16_ELEMENTS, int16_t>(
16244 i::kExternalInt16Array, -0x8000, 0x7FFF);
16245}
16246
16247
16248THREADED_TEST(FixedUint32Array)static void TestFixedUint32Array(); RegisterThreadedTest register_FixedUint32Array
(TestFixedUint32Array, "FixedUint32Array"); static void TestFixedUint32Array
(); CcTest register_test_FixedUint32Array(TestFixedUint32Array
, "../test/cctest/test-api.cc", "FixedUint32Array", __null, true
, true); static void TestFixedUint32Array()
{
16249 FixedTypedArrayTestHelper<i::FixedUint32Array, i::UINT32_ELEMENTS, uint32_t>(
16250 i::kExternalUint32Array, 0x0, UINT_MAX(2147483647 *2U +1U));
16251}
16252
16253
16254THREADED_TEST(FixedInt32Array)static void TestFixedInt32Array(); RegisterThreadedTest register_FixedInt32Array
(TestFixedInt32Array, "FixedInt32Array"); static void TestFixedInt32Array
(); CcTest register_test_FixedInt32Array(TestFixedInt32Array,
"../test/cctest/test-api.cc", "FixedInt32Array", __null, true
, true); static void TestFixedInt32Array()
{
16255 FixedTypedArrayTestHelper<i::FixedInt32Array, i::INT32_ELEMENTS, int32_t>(
16256 i::kExternalInt32Array, INT_MIN(-2147483647 -1), INT_MAX2147483647);
16257}
16258
16259
16260THREADED_TEST(FixedFloat32Array)static void TestFixedFloat32Array(); RegisterThreadedTest register_FixedFloat32Array
(TestFixedFloat32Array, "FixedFloat32Array"); static void TestFixedFloat32Array
(); CcTest register_test_FixedFloat32Array(TestFixedFloat32Array
, "../test/cctest/test-api.cc", "FixedFloat32Array", __null, true
, true); static void TestFixedFloat32Array()
{
16261 FixedTypedArrayTestHelper<i::FixedFloat32Array, i::FLOAT32_ELEMENTS, float>(
16262 i::kExternalFloat32Array, -500, 500);
16263}
16264
16265
16266THREADED_TEST(FixedFloat64Array)static void TestFixedFloat64Array(); RegisterThreadedTest register_FixedFloat64Array
(TestFixedFloat64Array, "FixedFloat64Array"); static void TestFixedFloat64Array
(); CcTest register_test_FixedFloat64Array(TestFixedFloat64Array
, "../test/cctest/test-api.cc", "FixedFloat64Array", __null, true
, true); static void TestFixedFloat64Array()
{
16267 FixedTypedArrayTestHelper<i::FixedFloat64Array, i::FLOAT64_ELEMENTS, float>(
16268 i::kExternalFloat64Array, -500, 500);
16269}
16270
16271
16272template <typename ElementType, typename TypedArray, class ExternalArrayClass,
16273 class ArrayBufferType>
16274void TypedArrayTestHelper(i::ExternalArrayType array_type, int64_t low,
16275 int64_t high) {
16276 const int kElementCount = 50;
16277
16278 i::ScopedVector<ElementType> backing_store(kElementCount+2);
16279
16280 LocalContext env;
16281 v8::Isolate* isolate = env->GetIsolate();
16282 v8::HandleScope handle_scope(isolate);
16283
16284 Local<ArrayBufferType> ab =
16285 ArrayBufferType::New(isolate, backing_store.start(),
16286 (kElementCount + 2) * sizeof(ElementType));
16287 Local<TypedArray> ta =
16288 TypedArray::New(ab, 2*sizeof(ElementType), kElementCount);
16289 CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta);
16290 CHECK_EQ(kElementCount, static_cast<int>(ta->Length()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kElementCount
), (static_cast<int>(ta->Length())), "kElementCount"
" " "==" " " "static_cast<int>(ta->Length())")) { V8_Fatal
("../test/cctest/test-api.cc", 16290, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
16291 CHECK_EQ(2 * sizeof(ElementType), ta->ByteOffset())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2 * sizeof
(ElementType)), (ta->ByteOffset()), "2 * sizeof(ElementType)"
" " "==" " " "ta->ByteOffset()")) { V8_Fatal("../test/cctest/test-api.cc"
, 16291, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16292 CHECK_EQ(kElementCount * sizeof(ElementType), ta->ByteLength())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kElementCount
* sizeof(ElementType)), (ta->ByteLength()), "kElementCount * sizeof(ElementType)"
" " "==" " " "ta->ByteLength()")) { V8_Fatal("../test/cctest/test-api.cc"
, 16292, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16293 CHECK(ab->Equals(env.local(), ta->Buffer()).FromJust())do { if ((__builtin_expect(!!(!(ab->Equals(env.local(), ta
->Buffer()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 16293, "Check failed: %s.", "ab->Equals(env.local(), ta->Buffer()).FromJust()"
); } } while (0)
;
16294
16295 ElementType* data = backing_store.start() + 2;
16296 for (int i = 0; i < kElementCount; i++) {
16297 data[i] = static_cast<ElementType>(i);
16298 }
16299
16300 ObjectWithExternalArrayTestHelper<ExternalArrayClass, ElementType>(
16301 env.local(), ta, kElementCount, array_type, low, high);
16302}
16303
16304
16305THREADED_TEST(Uint8Array)static void TestUint8Array(); RegisterThreadedTest register_Uint8Array
(TestUint8Array, "Uint8Array"); static void TestUint8Array();
CcTest register_test_Uint8Array(TestUint8Array, "../test/cctest/test-api.cc"
, "Uint8Array", __null, true, true); static void TestUint8Array
()
{
16306 TypedArrayTestHelper<uint8_t, v8::Uint8Array, i::FixedUint8Array,
16307 v8::ArrayBuffer>(i::kExternalUint8Array, 0, 0xFF);
16308}
16309
16310
16311THREADED_TEST(Int8Array)static void TestInt8Array(); RegisterThreadedTest register_Int8Array
(TestInt8Array, "Int8Array"); static void TestInt8Array(); CcTest
register_test_Int8Array(TestInt8Array, "../test/cctest/test-api.cc"
, "Int8Array", __null, true, true); static void TestInt8Array
()
{
16312 TypedArrayTestHelper<int8_t, v8::Int8Array, i::FixedInt8Array,
16313 v8::ArrayBuffer>(i::kExternalInt8Array, -0x80, 0x7F);
16314}
16315
16316
16317THREADED_TEST(Uint16Array)static void TestUint16Array(); RegisterThreadedTest register_Uint16Array
(TestUint16Array, "Uint16Array"); static void TestUint16Array
(); CcTest register_test_Uint16Array(TestUint16Array, "../test/cctest/test-api.cc"
, "Uint16Array", __null, true, true); static void TestUint16Array
()
{
16318 TypedArrayTestHelper<uint16_t, v8::Uint16Array, i::FixedUint16Array,
16319 v8::ArrayBuffer>(i::kExternalUint16Array, 0, 0xFFFF);
16320}
16321
16322
16323THREADED_TEST(Int16Array)static void TestInt16Array(); RegisterThreadedTest register_Int16Array
(TestInt16Array, "Int16Array"); static void TestInt16Array();
CcTest register_test_Int16Array(TestInt16Array, "../test/cctest/test-api.cc"
, "Int16Array", __null, true, true); static void TestInt16Array
()
{
16324 TypedArrayTestHelper<int16_t, v8::Int16Array, i::FixedInt16Array,
16325 v8::ArrayBuffer>(i::kExternalInt16Array, -0x8000,
16326 0x7FFF);
16327}
16328
16329
16330THREADED_TEST(Uint32Array)static void TestUint32Array(); RegisterThreadedTest register_Uint32Array
(TestUint32Array, "Uint32Array"); static void TestUint32Array
(); CcTest register_test_Uint32Array(TestUint32Array, "../test/cctest/test-api.cc"
, "Uint32Array", __null, true, true); static void TestUint32Array
()
{
16331 TypedArrayTestHelper<uint32_t, v8::Uint32Array, i::FixedUint32Array,
16332 v8::ArrayBuffer>(i::kExternalUint32Array, 0, UINT_MAX(2147483647 *2U +1U));
16333}
16334
16335
16336THREADED_TEST(Int32Array)static void TestInt32Array(); RegisterThreadedTest register_Int32Array
(TestInt32Array, "Int32Array"); static void TestInt32Array();
CcTest register_test_Int32Array(TestInt32Array, "../test/cctest/test-api.cc"
, "Int32Array", __null, true, true); static void TestInt32Array
()
{
16337 TypedArrayTestHelper<int32_t, v8::Int32Array, i::FixedInt32Array,
16338 v8::ArrayBuffer>(i::kExternalInt32Array, INT_MIN(-2147483647 -1),
16339 INT_MAX2147483647);
16340}
16341
16342
16343THREADED_TEST(Float32Array)static void TestFloat32Array(); RegisterThreadedTest register_Float32Array
(TestFloat32Array, "Float32Array"); static void TestFloat32Array
(); CcTest register_test_Float32Array(TestFloat32Array, "../test/cctest/test-api.cc"
, "Float32Array", __null, true, true); static void TestFloat32Array
()
{
16344 TypedArrayTestHelper<float, v8::Float32Array, i::FixedFloat32Array,
16345 v8::ArrayBuffer>(i::kExternalFloat32Array, -500, 500);
16346}
16347
16348
16349THREADED_TEST(Float64Array)static void TestFloat64Array(); RegisterThreadedTest register_Float64Array
(TestFloat64Array, "Float64Array"); static void TestFloat64Array
(); CcTest register_test_Float64Array(TestFloat64Array, "../test/cctest/test-api.cc"
, "Float64Array", __null, true, true); static void TestFloat64Array
()
{
16350 TypedArrayTestHelper<double, v8::Float64Array, i::FixedFloat64Array,
16351 v8::ArrayBuffer>(i::kExternalFloat64Array, -500, 500);
16352}
16353
16354
16355THREADED_TEST(Uint8ClampedArray)static void TestUint8ClampedArray(); RegisterThreadedTest register_Uint8ClampedArray
(TestUint8ClampedArray, "Uint8ClampedArray"); static void TestUint8ClampedArray
(); CcTest register_test_Uint8ClampedArray(TestUint8ClampedArray
, "../test/cctest/test-api.cc", "Uint8ClampedArray", __null, true
, true); static void TestUint8ClampedArray()
{
16356 TypedArrayTestHelper<uint8_t, v8::Uint8ClampedArray,
16357 i::FixedUint8ClampedArray, v8::ArrayBuffer>(
16358 i::kExternalUint8ClampedArray, 0, 0xFF);
16359}
16360
16361
16362THREADED_TEST(DataView)static void TestDataView(); RegisterThreadedTest register_DataView
(TestDataView, "DataView"); static void TestDataView(); CcTest
register_test_DataView(TestDataView, "../test/cctest/test-api.cc"
, "DataView", __null, true, true); static void TestDataView()
{
16363 const int kSize = 50;
16364
16365 i::ScopedVector<uint8_t> backing_store(kSize+2);
16366
16367 LocalContext env;
16368 v8::Isolate* isolate = env->GetIsolate();
16369 v8::HandleScope handle_scope(isolate);
16370
16371 Local<v8::ArrayBuffer> ab =
16372 v8::ArrayBuffer::New(isolate, backing_store.start(), 2 + kSize);
16373 Local<v8::DataView> dv = v8::DataView::New(ab, 2, kSize);
16374 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv);
16375 CHECK_EQ(2u, dv->ByteOffset())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
dv->ByteOffset()), "2u" " " "==" " " "dv->ByteOffset()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16375, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16376 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kSize)
, (static_cast<int>(dv->ByteLength())), "kSize" " " "=="
" " "static_cast<int>(dv->ByteLength())")) { V8_Fatal
("../test/cctest/test-api.cc", 16376, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
16377 CHECK(ab->Equals(env.local(), dv->Buffer()).FromJust())do { if ((__builtin_expect(!!(!(ab->Equals(env.local(), dv
->Buffer()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 16377, "Check failed: %s.", "ab->Equals(env.local(), dv->Buffer()).FromJust()"
); } } while (0)
;
16378}
16379
16380
16381THREADED_TEST(SkipArrayBufferBackingStoreDuringGC)static void TestSkipArrayBufferBackingStoreDuringGC(); RegisterThreadedTest
register_SkipArrayBufferBackingStoreDuringGC(TestSkipArrayBufferBackingStoreDuringGC
, "SkipArrayBufferBackingStoreDuringGC"); static void TestSkipArrayBufferBackingStoreDuringGC
(); CcTest register_test_SkipArrayBufferBackingStoreDuringGC(
TestSkipArrayBufferBackingStoreDuringGC, "../test/cctest/test-api.cc"
, "SkipArrayBufferBackingStoreDuringGC", __null, true, true);
static void TestSkipArrayBufferBackingStoreDuringGC()
{
16382 LocalContext env;
16383 v8::Isolate* isolate = env->GetIsolate();
16384 v8::HandleScope handle_scope(isolate);
16385
16386 // Make sure the pointer looks like a heap object
16387 uint8_t* store_ptr = reinterpret_cast<uint8_t*>(i::kHeapObjectTag);
16388
16389 // Create ArrayBuffer with pointer-that-cannot-be-visited in the backing store
16390 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, store_ptr, 8);
16391
16392 // Should not crash
16393 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
16394 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
16395 CcTest::heap()->CollectAllGarbage();
16396 CcTest::heap()->CollectAllGarbage();
16397
16398 // Should not move the pointer
16399 CHECK_EQ(ab->GetContents().Data(), store_ptr)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (ab->
GetContents().Data()), (store_ptr), "ab->GetContents().Data()"
" " "==" " " "store_ptr")) { V8_Fatal("../test/cctest/test-api.cc"
, 16399, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16400}
16401
16402
16403THREADED_TEST(SkipArrayBufferDuringScavenge)static void TestSkipArrayBufferDuringScavenge(); RegisterThreadedTest
register_SkipArrayBufferDuringScavenge(TestSkipArrayBufferDuringScavenge
, "SkipArrayBufferDuringScavenge"); static void TestSkipArrayBufferDuringScavenge
(); CcTest register_test_SkipArrayBufferDuringScavenge(TestSkipArrayBufferDuringScavenge
, "../test/cctest/test-api.cc", "SkipArrayBufferDuringScavenge"
, __null, true, true); static void TestSkipArrayBufferDuringScavenge
()
{
16404 LocalContext env;
16405 v8::Isolate* isolate = env->GetIsolate();
16406 v8::HandleScope handle_scope(isolate);
16407
16408 // Make sure the pointer looks like a heap object
16409 Local<v8::Object> tmp = v8::Object::New(isolate);
16410 uint8_t* store_ptr =
16411 reinterpret_cast<uint8_t*>(*reinterpret_cast<uintptr_t*>(*tmp));
16412
16413 // Make `store_ptr` point to from space
16414 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
16415
16416 // Create ArrayBuffer with pointer-that-cannot-be-visited in the backing store
16417 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, store_ptr, 8);
16418
16419 // Should not crash,
16420 // i.e. backing store pointer should not be treated as a heap object pointer
16421 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
16422 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
16423
16424 // Use `ab` to silence compiler warning
16425 CHECK_EQ(ab->GetContents().Data(), store_ptr)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (ab->
GetContents().Data()), (store_ptr), "ab->GetContents().Data()"
" " "==" " " "store_ptr")) { V8_Fatal("../test/cctest/test-api.cc"
, 16425, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16426}
16427
16428
16429THREADED_TEST(SharedUint8Array)static void TestSharedUint8Array(); RegisterThreadedTest register_SharedUint8Array
(TestSharedUint8Array, "SharedUint8Array"); static void TestSharedUint8Array
(); CcTest register_test_SharedUint8Array(TestSharedUint8Array
, "../test/cctest/test-api.cc", "SharedUint8Array", __null, true
, true); static void TestSharedUint8Array()
{
16430 i::FLAG_harmony_sharedarraybuffer = true;
16431 TypedArrayTestHelper<uint8_t, v8::Uint8Array, i::FixedUint8Array,
16432 v8::SharedArrayBuffer>(i::kExternalUint8Array, 0, 0xFF);
16433}
16434
16435
16436THREADED_TEST(SharedInt8Array)static void TestSharedInt8Array(); RegisterThreadedTest register_SharedInt8Array
(TestSharedInt8Array, "SharedInt8Array"); static void TestSharedInt8Array
(); CcTest register_test_SharedInt8Array(TestSharedInt8Array,
"../test/cctest/test-api.cc", "SharedInt8Array", __null, true
, true); static void TestSharedInt8Array()
{
16437 i::FLAG_harmony_sharedarraybuffer = true;
16438 TypedArrayTestHelper<int8_t, v8::Int8Array, i::FixedInt8Array,
16439 v8::SharedArrayBuffer>(i::kExternalInt8Array, -0x80,
16440 0x7F);
16441}
16442
16443
16444THREADED_TEST(SharedUint16Array)static void TestSharedUint16Array(); RegisterThreadedTest register_SharedUint16Array
(TestSharedUint16Array, "SharedUint16Array"); static void TestSharedUint16Array
(); CcTest register_test_SharedUint16Array(TestSharedUint16Array
, "../test/cctest/test-api.cc", "SharedUint16Array", __null, true
, true); static void TestSharedUint16Array()
{
16445 i::FLAG_harmony_sharedarraybuffer = true;
16446 TypedArrayTestHelper<uint16_t, v8::Uint16Array, i::FixedUint16Array,
16447 v8::SharedArrayBuffer>(i::kExternalUint16Array, 0,
16448 0xFFFF);
16449}
16450
16451
16452THREADED_TEST(SharedInt16Array)static void TestSharedInt16Array(); RegisterThreadedTest register_SharedInt16Array
(TestSharedInt16Array, "SharedInt16Array"); static void TestSharedInt16Array
(); CcTest register_test_SharedInt16Array(TestSharedInt16Array
, "../test/cctest/test-api.cc", "SharedInt16Array", __null, true
, true); static void TestSharedInt16Array()
{
16453 i::FLAG_harmony_sharedarraybuffer = true;
16454 TypedArrayTestHelper<int16_t, v8::Int16Array, i::FixedInt16Array,
16455 v8::SharedArrayBuffer>(i::kExternalInt16Array, -0x8000,
16456 0x7FFF);
16457}
16458
16459
16460THREADED_TEST(SharedUint32Array)static void TestSharedUint32Array(); RegisterThreadedTest register_SharedUint32Array
(TestSharedUint32Array, "SharedUint32Array"); static void TestSharedUint32Array
(); CcTest register_test_SharedUint32Array(TestSharedUint32Array
, "../test/cctest/test-api.cc", "SharedUint32Array", __null, true
, true); static void TestSharedUint32Array()
{
16461 i::FLAG_harmony_sharedarraybuffer = true;
16462 TypedArrayTestHelper<uint32_t, v8::Uint32Array, i::FixedUint32Array,
16463 v8::SharedArrayBuffer>(i::kExternalUint32Array, 0,
16464 UINT_MAX(2147483647 *2U +1U));
16465}
16466
16467
16468THREADED_TEST(SharedInt32Array)static void TestSharedInt32Array(); RegisterThreadedTest register_SharedInt32Array
(TestSharedInt32Array, "SharedInt32Array"); static void TestSharedInt32Array
(); CcTest register_test_SharedInt32Array(TestSharedInt32Array
, "../test/cctest/test-api.cc", "SharedInt32Array", __null, true
, true); static void TestSharedInt32Array()
{
16469 i::FLAG_harmony_sharedarraybuffer = true;
16470 TypedArrayTestHelper<int32_t, v8::Int32Array, i::FixedInt32Array,
16471 v8::SharedArrayBuffer>(i::kExternalInt32Array, INT_MIN(-2147483647 -1),
16472 INT_MAX2147483647);
16473}
16474
16475
16476THREADED_TEST(SharedFloat32Array)static void TestSharedFloat32Array(); RegisterThreadedTest register_SharedFloat32Array
(TestSharedFloat32Array, "SharedFloat32Array"); static void TestSharedFloat32Array
(); CcTest register_test_SharedFloat32Array(TestSharedFloat32Array
, "../test/cctest/test-api.cc", "SharedFloat32Array", __null,
true, true); static void TestSharedFloat32Array()
{
16477 i::FLAG_harmony_sharedarraybuffer = true;
16478 TypedArrayTestHelper<float, v8::Float32Array, i::FixedFloat32Array,
16479 v8::SharedArrayBuffer>(i::kExternalFloat32Array, -500,
16480 500);
16481}
16482
16483
16484THREADED_TEST(SharedFloat64Array)static void TestSharedFloat64Array(); RegisterThreadedTest register_SharedFloat64Array
(TestSharedFloat64Array, "SharedFloat64Array"); static void TestSharedFloat64Array
(); CcTest register_test_SharedFloat64Array(TestSharedFloat64Array
, "../test/cctest/test-api.cc", "SharedFloat64Array", __null,
true, true); static void TestSharedFloat64Array()
{
16485 i::FLAG_harmony_sharedarraybuffer = true;
16486 TypedArrayTestHelper<double, v8::Float64Array, i::FixedFloat64Array,
16487 v8::SharedArrayBuffer>(i::kExternalFloat64Array, -500,
16488 500);
16489}
16490
16491
16492THREADED_TEST(SharedUint8ClampedArray)static void TestSharedUint8ClampedArray(); RegisterThreadedTest
register_SharedUint8ClampedArray(TestSharedUint8ClampedArray
, "SharedUint8ClampedArray"); static void TestSharedUint8ClampedArray
(); CcTest register_test_SharedUint8ClampedArray(TestSharedUint8ClampedArray
, "../test/cctest/test-api.cc", "SharedUint8ClampedArray", __null
, true, true); static void TestSharedUint8ClampedArray()
{
16493 i::FLAG_harmony_sharedarraybuffer = true;
16494 TypedArrayTestHelper<uint8_t, v8::Uint8ClampedArray,
16495 i::FixedUint8ClampedArray, v8::SharedArrayBuffer>(
16496 i::kExternalUint8ClampedArray, 0, 0xFF);
16497}
16498
16499
16500THREADED_TEST(SharedDataView)static void TestSharedDataView(); RegisterThreadedTest register_SharedDataView
(TestSharedDataView, "SharedDataView"); static void TestSharedDataView
(); CcTest register_test_SharedDataView(TestSharedDataView, "../test/cctest/test-api.cc"
, "SharedDataView", __null, true, true); static void TestSharedDataView
()
{
16501 i::FLAG_harmony_sharedarraybuffer = true;
16502 const int kSize = 50;
16503
16504 i::ScopedVector<uint8_t> backing_store(kSize + 2);
16505
16506 LocalContext env;
16507 v8::Isolate* isolate = env->GetIsolate();
16508 v8::HandleScope handle_scope(isolate);
16509
16510 Local<v8::SharedArrayBuffer> ab =
16511 v8::SharedArrayBuffer::New(isolate, backing_store.start(), 2 + kSize);
16512 Local<v8::DataView> dv =
16513 v8::DataView::New(ab, 2, kSize);
16514 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv);
16515 CHECK_EQ(2u, dv->ByteOffset())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2u), (
dv->ByteOffset()), "2u" " " "==" " " "dv->ByteOffset()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16515, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16516 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kSize)
, (static_cast<int>(dv->ByteLength())), "kSize" " " "=="
" " "static_cast<int>(dv->ByteLength())")) { V8_Fatal
("../test/cctest/test-api.cc", 16516, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
16517 CHECK(ab->Equals(env.local(), dv->Buffer()).FromJust())do { if ((__builtin_expect(!!(!(ab->Equals(env.local(), dv
->Buffer()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 16517, "Check failed: %s.", "ab->Equals(env.local(), dv->Buffer()).FromJust()"
); } } while (0)
;
16518}
16519
16520
16521#define IS_ARRAY_BUFFER_VIEW_TEST(View) \
16522 THREADED_TEST(Is##View)static void TestIs##View(); RegisterThreadedTest register_Is##
View(TestIs##View, "Is##View"); static void TestIs##View(); CcTest
register_test_Is##View(TestIs##View, "../test/cctest/test-api.cc"
, "Is##View", __null, true, true); static void TestIs##View()
{ \
16523 LocalContext env; \
16524 v8::Isolate* isolate = env->GetIsolate(); \
16525 v8::HandleScope handle_scope(isolate); \
16526 \
16527 Local<Value> result = CompileRun( \
16528 "var ab = new ArrayBuffer(128);" \
16529 "new " #View "(ab)"); \
16530 CHECK(result->IsArrayBufferView())do { if ((__builtin_expect(!!(!(result->IsArrayBufferView(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16530, "Check failed: %s."
, "result->IsArrayBufferView()"); } } while (0)
; \
16531 CHECK(result->Is##View())do { if ((__builtin_expect(!!(!(result->Is##View())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 16531, "Check failed: %s."
, "result->Is##View()"); } } while (0)
; \
16532 CheckInternalFieldsAreZero<v8::ArrayBufferView>(result.As<v8::View>()); \
16533 }
16534
16535IS_ARRAY_BUFFER_VIEW_TEST(Uint8Array)
16536IS_ARRAY_BUFFER_VIEW_TEST(Int8Array)
16537IS_ARRAY_BUFFER_VIEW_TEST(Uint16Array)
16538IS_ARRAY_BUFFER_VIEW_TEST(Int16Array)
16539IS_ARRAY_BUFFER_VIEW_TEST(Uint32Array)
16540IS_ARRAY_BUFFER_VIEW_TEST(Int32Array)
16541IS_ARRAY_BUFFER_VIEW_TEST(Float32Array)
16542IS_ARRAY_BUFFER_VIEW_TEST(Float64Array)
16543IS_ARRAY_BUFFER_VIEW_TEST(Uint8ClampedArray)
16544IS_ARRAY_BUFFER_VIEW_TEST(DataView)
16545
16546#undef IS_ARRAY_BUFFER_VIEW_TEST
16547
16548
16549
16550THREADED_TEST(ScriptContextDependence)static void TestScriptContextDependence(); RegisterThreadedTest
register_ScriptContextDependence(TestScriptContextDependence
, "ScriptContextDependence"); static void TestScriptContextDependence
(); CcTest register_test_ScriptContextDependence(TestScriptContextDependence
, "../test/cctest/test-api.cc", "ScriptContextDependence", __null
, true, true); static void TestScriptContextDependence()
{
16551 LocalContext c1;
16552 v8::HandleScope scope(c1->GetIsolate());
16553 const char *source = "foo";
16554 v8::Local<v8::Script> dep = v8_compile(source);
16555 v8::ScriptCompiler::Source script_source(
16556 v8::String::NewFromUtf8(c1->GetIsolate(), source,
16557 v8::NewStringType::kNormal)
16558 .ToLocalChecked());
16559 v8::Local<v8::UnboundScript> indep =
16560 v8::ScriptCompiler::CompileUnboundScript(c1->GetIsolate(), &script_source)
16561 .ToLocalChecked();
16562 c1->Global()
16563 ->Set(c1.local(), v8::String::NewFromUtf8(c1->GetIsolate(), "foo",
16564 v8::NewStringType::kNormal)
16565 .ToLocalChecked(),
16566 v8::Integer::New(c1->GetIsolate(), 100))
16567 .FromJust();
16568 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (dep->
Run(c1.local()).ToLocalChecked()->Int32Value(c1.local()).FromJust
()), (100), "dep->Run(c1.local()).ToLocalChecked()->Int32Value(c1.local()).FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16570, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16569 dep->Run(c1.local()).ToLocalChecked()->Int32Value(c1.local()).FromJust(),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (dep->
Run(c1.local()).ToLocalChecked()->Int32Value(c1.local()).FromJust
()), (100), "dep->Run(c1.local()).ToLocalChecked()->Int32Value(c1.local()).FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16570, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16570 100)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (dep->
Run(c1.local()).ToLocalChecked()->Int32Value(c1.local()).FromJust
()), (100), "dep->Run(c1.local()).ToLocalChecked()->Int32Value(c1.local()).FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16570, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16571 CHECK_EQ(indep->BindToCurrentContext()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked()
->Int32Value(c1.local()) .FromJust()), (100), "indep->BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked() ->Int32Value(c1.local()) .FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16576, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16572 ->Run(c1.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked()
->Int32Value(c1.local()) .FromJust()), (100), "indep->BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked() ->Int32Value(c1.local()) .FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16576, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16573 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked()
->Int32Value(c1.local()) .FromJust()), (100), "indep->BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked() ->Int32Value(c1.local()) .FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16576, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16574 ->Int32Value(c1.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked()
->Int32Value(c1.local()) .FromJust()), (100), "indep->BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked() ->Int32Value(c1.local()) .FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16576, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16575 .FromJust(),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked()
->Int32Value(c1.local()) .FromJust()), (100), "indep->BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked() ->Int32Value(c1.local()) .FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16576, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16576 100)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked()
->Int32Value(c1.local()) .FromJust()), (100), "indep->BindToCurrentContext() ->Run(c1.local()) .ToLocalChecked() ->Int32Value(c1.local()) .FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16576, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16577 LocalContext c2;
16578 c2->Global()
16579 ->Set(c2.local(), v8::String::NewFromUtf8(c2->GetIsolate(), "foo",
16580 v8::NewStringType::kNormal)
16581 .ToLocalChecked(),
16582 v8::Integer::New(c2->GetIsolate(), 101))
16583 .FromJust();
16584 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (dep->
Run(c2.local()).ToLocalChecked()->Int32Value(c2.local()).FromJust
()), (100), "dep->Run(c2.local()).ToLocalChecked()->Int32Value(c2.local()).FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16586, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16585 dep->Run(c2.local()).ToLocalChecked()->Int32Value(c2.local()).FromJust(),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (dep->
Run(c2.local()).ToLocalChecked()->Int32Value(c2.local()).FromJust
()), (100), "dep->Run(c2.local()).ToLocalChecked()->Int32Value(c2.local()).FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16586, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16586 100)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (dep->
Run(c2.local()).ToLocalChecked()->Int32Value(c2.local()).FromJust
()), (100), "dep->Run(c2.local()).ToLocalChecked()->Int32Value(c2.local()).FromJust()"
" " "==" " " "100")) { V8_Fatal("../test/cctest/test-api.cc"
, 16586, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16587 CHECK_EQ(indep->BindToCurrentContext()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked()
->Int32Value(c2.local()) .FromJust()), (101), "indep->BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked() ->Int32Value(c2.local()) .FromJust()"
" " "==" " " "101")) { V8_Fatal("../test/cctest/test-api.cc"
, 16592, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16588 ->Run(c2.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked()
->Int32Value(c2.local()) .FromJust()), (101), "indep->BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked() ->Int32Value(c2.local()) .FromJust()"
" " "==" " " "101")) { V8_Fatal("../test/cctest/test-api.cc"
, 16592, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16589 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked()
->Int32Value(c2.local()) .FromJust()), (101), "indep->BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked() ->Int32Value(c2.local()) .FromJust()"
" " "==" " " "101")) { V8_Fatal("../test/cctest/test-api.cc"
, 16592, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16590 ->Int32Value(c2.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked()
->Int32Value(c2.local()) .FromJust()), (101), "indep->BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked() ->Int32Value(c2.local()) .FromJust()"
" " "==" " " "101")) { V8_Fatal("../test/cctest/test-api.cc"
, 16592, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16591 .FromJust(),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked()
->Int32Value(c2.local()) .FromJust()), (101), "indep->BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked() ->Int32Value(c2.local()) .FromJust()"
" " "==" " " "101")) { V8_Fatal("../test/cctest/test-api.cc"
, 16592, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
16592 101)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (indep->
BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked()
->Int32Value(c2.local()) .FromJust()), (101), "indep->BindToCurrentContext() ->Run(c2.local()) .ToLocalChecked() ->Int32Value(c2.local()) .FromJust()"
" " "==" " " "101")) { V8_Fatal("../test/cctest/test-api.cc"
, 16592, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16593}
16594
16595
16596THREADED_TEST(StackTrace)static void TestStackTrace(); RegisterThreadedTest register_StackTrace
(TestStackTrace, "StackTrace"); static void TestStackTrace();
CcTest register_test_StackTrace(TestStackTrace, "../test/cctest/test-api.cc"
, "StackTrace", __null, true, true); static void TestStackTrace
()
{
16597 LocalContext context;
16598 v8::HandleScope scope(context->GetIsolate());
16599 v8::TryCatch try_catch(context->GetIsolate());
16600 const char *source = "function foo() { FAIL.FAIL; }; foo();";
16601 v8::Local<v8::String> src = v8_str(source);
16602 v8::Local<v8::String> origin = v8_str("stack-trace-test");
16603 v8::ScriptCompiler::Source script_source(src, v8::ScriptOrigin(origin));
16604 CHECK(v8::ScriptCompiler::CompileUnboundScript(context->GetIsolate(),do { if ((__builtin_expect(!!(!(v8::ScriptCompiler::CompileUnboundScript
(context->GetIsolate(), &script_source) .ToLocalChecked
() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16609, "Check failed: %s."
, "v8::ScriptCompiler::CompileUnboundScript(context->GetIsolate(), &script_source) .ToLocalChecked() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty()"
); } } while (0)
16605 &script_source)do { if ((__builtin_expect(!!(!(v8::ScriptCompiler::CompileUnboundScript
(context->GetIsolate(), &script_source) .ToLocalChecked
() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16609, "Check failed: %s."
, "v8::ScriptCompiler::CompileUnboundScript(context->GetIsolate(), &script_source) .ToLocalChecked() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty()"
); } } while (0)
16606 .ToLocalChecked()do { if ((__builtin_expect(!!(!(v8::ScriptCompiler::CompileUnboundScript
(context->GetIsolate(), &script_source) .ToLocalChecked
() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16609, "Check failed: %s."
, "v8::ScriptCompiler::CompileUnboundScript(context->GetIsolate(), &script_source) .ToLocalChecked() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty()"
); } } while (0)
16607 ->BindToCurrentContext()do { if ((__builtin_expect(!!(!(v8::ScriptCompiler::CompileUnboundScript
(context->GetIsolate(), &script_source) .ToLocalChecked
() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16609, "Check failed: %s."
, "v8::ScriptCompiler::CompileUnboundScript(context->GetIsolate(), &script_source) .ToLocalChecked() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty()"
); } } while (0)
16608 ->Run(context.local())do { if ((__builtin_expect(!!(!(v8::ScriptCompiler::CompileUnboundScript
(context->GetIsolate(), &script_source) .ToLocalChecked
() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16609, "Check failed: %s."
, "v8::ScriptCompiler::CompileUnboundScript(context->GetIsolate(), &script_source) .ToLocalChecked() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty()"
); } } while (0)
16609 .IsEmpty())do { if ((__builtin_expect(!!(!(v8::ScriptCompiler::CompileUnboundScript
(context->GetIsolate(), &script_source) .ToLocalChecked
() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16609, "Check failed: %s."
, "v8::ScriptCompiler::CompileUnboundScript(context->GetIsolate(), &script_source) .ToLocalChecked() ->BindToCurrentContext() ->Run(context.local()) .IsEmpty()"
); } } while (0)
;
16610 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 16610, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
16611 v8::String::Utf8Value stack(
16612 try_catch.StackTrace(context.local()).ToLocalChecked());
16613 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL)do { if ((__builtin_expect(!!(!(strstr(*stack, "at foo (stack-trace-test"
) != __null)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16613
, "Check failed: %s.", "strstr(*stack, \"at foo (stack-trace-test\") != NULL"
); } } while (0)
;
16614}
16615
16616
16617// Checks that a StackFrame has certain expected values.
16618void checkStackFrame(const char* expected_script_name,
16619 const char* expected_func_name, int expected_line_number,
16620 int expected_column, bool is_eval, bool is_constructor,
16621 v8::Local<v8::StackFrame> frame) {
16622 v8::HandleScope scope(CcTest::isolate());
16623 v8::String::Utf8Value func_name(frame->GetFunctionName());
16624 v8::String::Utf8Value script_name(frame->GetScriptName());
16625 if (*script_name == NULL__null) {
7
Taking false branch
16626 // The situation where there is no associated script, like for evals.
16627 CHECK(expected_script_name == NULL)do { if ((__builtin_expect(!!(!(expected_script_name == __null
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16627, "Check failed: %s."
, "expected_script_name == NULL"); } } while (0)
;
16628 } else {
16629 CHECK(strstr(*script_name, expected_script_name) != NULL)do { if ((__builtin_expect(!!(!(strstr(*script_name, expected_script_name
) != __null)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16629
, "Check failed: %s.", "strstr(*script_name, expected_script_name) != NULL"
); } } while (0)
;
8
Within the expansion of the macro 'CHECK':
a
Null pointer passed as an argument to a 'nonnull' parameter
16630 }
16631 CHECK(strstr(*func_name, expected_func_name) != NULL)do { if ((__builtin_expect(!!(!(strstr(*func_name, expected_func_name
) != __null)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16631
, "Check failed: %s.", "strstr(*func_name, expected_func_name) != NULL"
); } } while (0)
;
16632 CHECK_EQ(expected_line_number, frame->GetLineNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected_line_number
), (frame->GetLineNumber()), "expected_line_number" " " "=="
" " "frame->GetLineNumber()")) { V8_Fatal("../test/cctest/test-api.cc"
, 16632, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16633 CHECK_EQ(expected_column, frame->GetColumn())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected_column
), (frame->GetColumn()), "expected_column" " " "==" " " "frame->GetColumn()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16633, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16634 CHECK_EQ(is_eval, frame->IsEval())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (is_eval
), (frame->IsEval()), "is_eval" " " "==" " " "frame->IsEval()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16634, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16635 CHECK_EQ(is_constructor, frame->IsConstructor())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (is_constructor
), (frame->IsConstructor()), "is_constructor" " " "==" " "
"frame->IsConstructor()")) { V8_Fatal("../test/cctest/test-api.cc"
, 16635, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16636}
16637
16638
16639void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) {
16640 v8::HandleScope scope(args.GetIsolate());
16641 const char* origin = "capture-stack-trace-test";
16642 const int kOverviewTest = 1;
16643 const int kDetailedTest = 2;
16644 const int kFunctionName = 3;
16645 const int kDisplayName = 4;
16646 const int kFunctionNameAndDisplayName = 5;
16647 const int kDisplayNameIsNotString = 6;
16648 const int kFunctionNameIsNotString = 7;
16649
16650 CHECK(args.Length() == 1)do { if ((__builtin_expect(!!(!(args.Length() == 1)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 16650, "Check failed: %s.", "args.Length() == 1"
); } } while (0)
;
16651
16652 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
16653 int testGroup = args[0]->Int32Value(context).FromJust();
16654 if (testGroup == kOverviewTest) {
1
Assuming 'testGroup' is not equal to 'kOverviewTest'
2
Taking false branch
16655 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16656 args.GetIsolate(), 10, v8::StackTrace::kOverview);
16657 CHECK_EQ(4, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (stackTrace
->GetFrameCount()), "4" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16657, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16658 checkStackFrame(origin, "bar", 2, 10, false, false,
16659 stackTrace->GetFrame(0));
16660 checkStackFrame(origin, "foo", 6, 3, false, false,
16661 stackTrace->GetFrame(1));
16662 // This is the source string inside the eval which has the call to foo.
16663 checkStackFrame(NULL__null, "", 1, 1, false, false, stackTrace->GetFrame(2));
16664 // The last frame is an anonymous function which has the initial eval call.
16665 checkStackFrame(origin, "", 8, 7, false, false, stackTrace->GetFrame(3));
16666
16667 CHECK(stackTrace->AsArray()->IsArray())do { if ((__builtin_expect(!!(!(stackTrace->AsArray()->
IsArray())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16667
, "Check failed: %s.", "stackTrace->AsArray()->IsArray()"
); } } while (0)
;
16668 } else if (testGroup == kDetailedTest) {
3
Assuming 'testGroup' is equal to 'kDetailedTest'
4
Taking true branch
16669 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16670 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
16671 CHECK_EQ(4, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (stackTrace
->GetFrameCount()), "4" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16671, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16672 checkStackFrame(origin, "bat", 4, 22, false, false,
16673 stackTrace->GetFrame(0));
16674 checkStackFrame(origin, "baz", 8, 3, false, true,
16675 stackTrace->GetFrame(1));
16676 bool is_eval = true;
16677 // This is the source string inside the eval which has the call to baz.
16678 checkStackFrame(NULL__null, "", 1, 1, is_eval, false, stackTrace->GetFrame(2));
5
Within the expansion of the macro 'NULL':
a
Passing null pointer value via 1st parameter 'expected_script_name'
6
Calling 'checkStackFrame'
16679 // The last frame is an anonymous function which has the initial eval call.
16680 checkStackFrame(origin, "", 10, 1, false, false, stackTrace->GetFrame(3));
16681
16682 CHECK(stackTrace->AsArray()->IsArray())do { if ((__builtin_expect(!!(!(stackTrace->AsArray()->
IsArray())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16682
, "Check failed: %s.", "stackTrace->AsArray()->IsArray()"
); } } while (0)
;
16683 } else if (testGroup == kFunctionName) {
16684 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16685 args.GetIsolate(), 5, v8::StackTrace::kOverview);
16686 CHECK_EQ(3, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (stackTrace
->GetFrameCount()), "3" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16686, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16687 checkStackFrame(origin, "function.name", 2, 24, false, false,
16688 stackTrace->GetFrame(0));
16689 } else if (testGroup == kDisplayName) {
16690 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16691 args.GetIsolate(), 5, v8::StackTrace::kOverview);
16692 CHECK_EQ(3, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (stackTrace
->GetFrameCount()), "3" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16692, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16693 checkStackFrame(origin, "function.displayName", 2, 24, false, false,
16694 stackTrace->GetFrame(0));
16695 } else if (testGroup == kFunctionNameAndDisplayName) {
16696 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16697 args.GetIsolate(), 5, v8::StackTrace::kOverview);
16698 CHECK_EQ(3, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (stackTrace
->GetFrameCount()), "3" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16698, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16699 checkStackFrame(origin, "function.displayName", 2, 24, false, false,
16700 stackTrace->GetFrame(0));
16701 } else if (testGroup == kDisplayNameIsNotString) {
16702 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16703 args.GetIsolate(), 5, v8::StackTrace::kOverview);
16704 CHECK_EQ(3, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (stackTrace
->GetFrameCount()), "3" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16704, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16705 checkStackFrame(origin, "function.name", 2, 24, false, false,
16706 stackTrace->GetFrame(0));
16707 } else if (testGroup == kFunctionNameIsNotString) {
16708 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16709 args.GetIsolate(), 5, v8::StackTrace::kOverview);
16710 CHECK_EQ(3, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (stackTrace
->GetFrameCount()), "3" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16710, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16711 checkStackFrame(origin, "f", 2, 24, false, false, stackTrace->GetFrame(0));
16712 }
16713}
16714
16715
16716// Tests the C++ StackTrace API.
16717// TODO(3074796): Reenable this as a THREADED_TEST once it passes.
16718// THREADED_TEST(CaptureStackTrace) {
16719TEST(CaptureStackTrace)static void TestCaptureStackTrace(); CcTest register_test_CaptureStackTrace
(TestCaptureStackTrace, "../test/cctest/test-api.cc", "CaptureStackTrace"
, __null, true, true); static void TestCaptureStackTrace()
{
16720 v8::Isolate* isolate = CcTest::isolate();
16721 v8::HandleScope scope(isolate);
16722 v8::Local<v8::String> origin = v8_str("capture-stack-trace-test");
16723 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
16724 templ->Set(v8_str("AnalyzeStackInNativeCode"),
16725 v8::FunctionTemplate::New(isolate, AnalyzeStackInNativeCode));
16726 LocalContext context(0, templ);
16727
16728 // Test getting OVERVIEW information. Should ignore information that is not
16729 // script name, function name, line number, and column offset.
16730 const char *overview_source =
16731 "function bar() {\n"
16732 " var y; AnalyzeStackInNativeCode(1);\n"
16733 "}\n"
16734 "function foo() {\n"
16735 "\n"
16736 " bar();\n"
16737 "}\n"
16738 "var x;eval('new foo();');";
16739 v8::Local<v8::String> overview_src = v8_str(overview_source);
16740 v8::ScriptCompiler::Source script_source(overview_src,
16741 v8::ScriptOrigin(origin));
16742 v8::Local<Value> overview_result(
16743 v8::ScriptCompiler::CompileUnboundScript(isolate, &script_source)
16744 .ToLocalChecked()
16745 ->BindToCurrentContext()
16746 ->Run(context.local())
16747 .ToLocalChecked());
16748 CHECK(!overview_result.IsEmpty())do { if ((__builtin_expect(!!(!(!overview_result.IsEmpty())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 16748, "Check failed: %s."
, "!overview_result.IsEmpty()"); } } while (0)
;
16749 CHECK(overview_result->IsObject())do { if ((__builtin_expect(!!(!(overview_result->IsObject(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16749, "Check failed: %s."
, "overview_result->IsObject()"); } } while (0)
;
16750
16751 // Test getting DETAILED information.
16752 const char *detailed_source =
16753 "function bat() {AnalyzeStackInNativeCode(2);\n"
16754 "}\n"
16755 "\n"
16756 "function baz() {\n"
16757 " bat();\n"
16758 "}\n"
16759 "eval('new baz();');";
16760 v8::Local<v8::String> detailed_src = v8_str(detailed_source);
16761 // Make the script using a non-zero line and column offset.
16762 v8::Local<v8::Integer> line_offset = v8::Integer::New(isolate, 3);
16763 v8::Local<v8::Integer> column_offset = v8::Integer::New(isolate, 5);
16764 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset);
16765 v8::ScriptCompiler::Source script_source2(detailed_src, detailed_origin);
16766 v8::Local<v8::UnboundScript> detailed_script(
16767 v8::ScriptCompiler::CompileUnboundScript(isolate, &script_source2)
16768 .ToLocalChecked());
16769 v8::Local<Value> detailed_result(detailed_script->BindToCurrentContext()
16770 ->Run(context.local())
16771 .ToLocalChecked());
16772 CHECK(!detailed_result.IsEmpty())do { if ((__builtin_expect(!!(!(!detailed_result.IsEmpty())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 16772, "Check failed: %s."
, "!detailed_result.IsEmpty()"); } } while (0)
;
16773 CHECK(detailed_result->IsObject())do { if ((__builtin_expect(!!(!(detailed_result->IsObject(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16773, "Check failed: %s."
, "detailed_result->IsObject()"); } } while (0)
;
16774
16775 // Test using function.name and function.displayName in stack trace
16776 const char* function_name_source =
16777 "function bar(function_name, display_name, testGroup) {\n"
16778 " var f = function() { AnalyzeStackInNativeCode(testGroup); };\n"
16779 " if (function_name) {\n"
16780 " Object.defineProperty(f, 'name', { value: function_name });\n"
16781 " }\n"
16782 " if (display_name) {\n"
16783 " f.displayName = display_name;"
16784 " }\n"
16785 " f()\n"
16786 "}\n"
16787 "bar('function.name', undefined, 3);\n"
16788 "bar(undefined, 'function.displayName', 4);\n"
16789 "bar('function.name', 'function.displayName', 5);\n"
16790 "bar('function.name', 239, 6);\n"
16791 "bar(239, undefined, 7);\n";
16792 v8::Local<v8::String> function_name_src =
16793 v8::String::NewFromUtf8(isolate, function_name_source,
16794 v8::NewStringType::kNormal)
16795 .ToLocalChecked();
16796 v8::ScriptCompiler::Source script_source3(function_name_src,
16797 v8::ScriptOrigin(origin));
16798 v8::Local<Value> function_name_result(
16799 v8::ScriptCompiler::CompileUnboundScript(isolate, &script_source3)
16800 .ToLocalChecked()
16801 ->BindToCurrentContext()
16802 ->Run(context.local())
16803 .ToLocalChecked());
16804 CHECK(!function_name_result.IsEmpty())do { if ((__builtin_expect(!!(!(!function_name_result.IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 16804, "Check failed: %s."
, "!function_name_result.IsEmpty()"); } } while (0)
;
16805}
16806
16807
16808static void StackTraceForUncaughtExceptionListener(
16809 v8::Local<v8::Message> message, v8::Local<Value>) {
16810 report_count++;
16811 v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
16812 CHECK_EQ(2, stack_trace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (stack_trace
->GetFrameCount()), "2" " " "==" " " "stack_trace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16812, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16813 checkStackFrame("origin", "foo", 2, 3, false, false,
16814 stack_trace->GetFrame(0));
16815 checkStackFrame("origin", "bar", 5, 3, false, false,
16816 stack_trace->GetFrame(1));
16817}
16818
16819
16820TEST(CaptureStackTraceForUncaughtException)static void TestCaptureStackTraceForUncaughtException(); CcTest
register_test_CaptureStackTraceForUncaughtException(TestCaptureStackTraceForUncaughtException
, "../test/cctest/test-api.cc", "CaptureStackTraceForUncaughtException"
, __null, true, true); static void TestCaptureStackTraceForUncaughtException
()
{
16821 report_count = 0;
16822 LocalContext env;
16823 v8::Isolate* isolate = env->GetIsolate();
16824 v8::HandleScope scope(isolate);
16825 isolate->AddMessageListener(StackTraceForUncaughtExceptionListener);
16826 isolate->SetCaptureStackTraceForUncaughtExceptions(true);
16827
16828 CompileRunWithOrigin(
16829 "function foo() {\n"
16830 " throw 1;\n"
16831 "};\n"
16832 "function bar() {\n"
16833 " foo();\n"
16834 "};",
16835 "origin");
16836 v8::Local<v8::Object> global = env->Global();
16837 Local<Value> trouble =
16838 global->Get(env.local(), v8_str("bar")).ToLocalChecked();
16839 CHECK(trouble->IsFunction())do { if ((__builtin_expect(!!(!(trouble->IsFunction())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 16839, "Check failed: %s."
, "trouble->IsFunction()"); } } while (0)
;
16840 CHECK(Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).IsEmpty())do { if ((__builtin_expect(!!(!(Function::Cast(*trouble)->
Call(env.local(), global, 0, __null).IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 16840, "Check failed: %s.", "Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).IsEmpty()"
); } } while (0)
;
16841 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
16842 isolate->RemoveMessageListeners(StackTraceForUncaughtExceptionListener);
16843 CHECK_EQ(1, report_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (report_count
), "1" " " "==" " " "report_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 16843, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16844}
16845
16846
16847TEST(GetStackTraceForUncaughtExceptionFromSimpleStackTrace)static void TestGetStackTraceForUncaughtExceptionFromSimpleStackTrace
(); CcTest register_test_GetStackTraceForUncaughtExceptionFromSimpleStackTrace
(TestGetStackTraceForUncaughtExceptionFromSimpleStackTrace, "../test/cctest/test-api.cc"
, "GetStackTraceForUncaughtExceptionFromSimpleStackTrace", __null
, true, true); static void TestGetStackTraceForUncaughtExceptionFromSimpleStackTrace
()
{
16848 report_count = 0;
16849 LocalContext env;
16850 v8::Isolate* isolate = env->GetIsolate();
16851 v8::HandleScope scope(isolate);
16852
16853 // Create an Error object first.
16854 CompileRunWithOrigin(
16855 "function foo() {\n"
16856 "e=new Error('err');\n"
16857 "};\n"
16858 "function bar() {\n"
16859 " foo();\n"
16860 "};\n"
16861 "var e;",
16862 "origin");
16863 v8::Local<v8::Object> global = env->Global();
16864 Local<Value> trouble =
16865 global->Get(env.local(), v8_str("bar")).ToLocalChecked();
16866 CHECK(trouble->IsFunction())do { if ((__builtin_expect(!!(!(trouble->IsFunction())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 16866, "Check failed: %s."
, "trouble->IsFunction()"); } } while (0)
;
16867 Function::Cast(*trouble)->Call(env.local(), global, 0, NULL__null).ToLocalChecked();
16868
16869 // Enable capturing detailed stack trace late, and throw the exception.
16870 // The detailed stack trace should be extracted from the simple stack.
16871 isolate->AddMessageListener(StackTraceForUncaughtExceptionListener);
16872 isolate->SetCaptureStackTraceForUncaughtExceptions(true);
16873 CompileRunWithOrigin("throw e", "origin");
16874 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
16875 isolate->RemoveMessageListeners(StackTraceForUncaughtExceptionListener);
16876 CHECK_EQ(1, report_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (report_count
), "1" " " "==" " " "report_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 16876, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16877}
16878
16879
16880TEST(CaptureStackTraceForUncaughtExceptionAndSetters)static void TestCaptureStackTraceForUncaughtExceptionAndSetters
(); CcTest register_test_CaptureStackTraceForUncaughtExceptionAndSetters
(TestCaptureStackTraceForUncaughtExceptionAndSetters, "../test/cctest/test-api.cc"
, "CaptureStackTraceForUncaughtExceptionAndSetters", __null, true
, true); static void TestCaptureStackTraceForUncaughtExceptionAndSetters
()
{
16881 LocalContext env;
16882 v8::Isolate* isolate = env->GetIsolate();
16883 v8::HandleScope scope(isolate);
16884 isolate->SetCaptureStackTraceForUncaughtExceptions(true, 1024,
16885 v8::StackTrace::kDetailed);
16886
16887 CompileRun(
16888 "var setters = ['column', 'lineNumber', 'scriptName',\n"
16889 " 'scriptNameOrSourceURL', 'functionName', 'isEval',\n"
16890 " 'isConstructor'];\n"
16891 "for (var i = 0; i < setters.length; i++) {\n"
16892 " var prop = setters[i];\n"
16893 " Object.prototype.__defineSetter__(prop, function() { throw prop; });\n"
16894 "}\n");
16895 CompileRun("throw 'exception';");
16896 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
16897}
16898
16899
16900static void StackTraceFunctionNameListener(v8::Local<v8::Message> message,
16901 v8::Local<Value>) {
16902 v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
16903 CHECK_EQ(5, stack_trace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (stack_trace
->GetFrameCount()), "5" " " "==" " " "stack_trace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16904 checkStackFrame("origin", "foo:0", 4, 7, false, false,
16905 stack_trace->GetFrame(0));
16906 checkStackFrame("origin", "foo:1", 5, 27, false, false,
16907 stack_trace->GetFrame(1));
16908 checkStackFrame("origin", "foo", 5, 27, false, false,
16909 stack_trace->GetFrame(2));
16910 checkStackFrame("origin", "foo", 5, 27, false, false,
16911 stack_trace->GetFrame(3));
16912 checkStackFrame("origin", "", 1, 14, false, false, stack_trace->GetFrame(4));
16913}
16914
16915
16916TEST(GetStackTraceContainsFunctionsWithFunctionName)static void TestGetStackTraceContainsFunctionsWithFunctionName
(); CcTest register_test_GetStackTraceContainsFunctionsWithFunctionName
(TestGetStackTraceContainsFunctionsWithFunctionName, "../test/cctest/test-api.cc"
, "GetStackTraceContainsFunctionsWithFunctionName", __null, true
, true); static void TestGetStackTraceContainsFunctionsWithFunctionName
()
{
16917 LocalContext env;
16918 v8::Isolate* isolate = env->GetIsolate();
16919 v8::HandleScope scope(isolate);
16920
16921 CompileRunWithOrigin(
16922 "function gen(name, counter) {\n"
16923 " var f = function foo() {\n"
16924 " if (counter === 0)\n"
16925 " throw 1;\n"
16926 " gen(name, counter - 1)();\n"
16927 " };\n"
16928 " if (counter == 3) {\n"
16929 " Object.defineProperty(f, 'name', {get: function(){ throw 239; }});\n"
16930 " } else {\n"
16931 " Object.defineProperty(f, 'name', {writable:true});\n"
16932 " if (counter == 2)\n"
16933 " f.name = 42;\n"
16934 " else\n"
16935 " f.name = name + ':' + counter;\n"
16936 " }\n"
16937 " return f;\n"
16938 "};",
16939 "origin");
16940
16941 isolate->AddMessageListener(StackTraceFunctionNameListener);
16942 isolate->SetCaptureStackTraceForUncaughtExceptions(true);
16943 CompileRunWithOrigin("gen('foo', 3)();", "origin");
16944 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
16945 isolate->RemoveMessageListeners(StackTraceFunctionNameListener);
16946}
16947
16948
16949static void RethrowStackTraceHandler(v8::Local<v8::Message> message,
16950 v8::Local<v8::Value> data) {
16951 // Use the frame where JavaScript is called from.
16952 v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
16953 CHECK(!stack_trace.IsEmpty())do { if ((__builtin_expect(!!(!(!stack_trace.IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 16953, "Check failed: %s."
, "!stack_trace.IsEmpty()"); } } while (0)
;
16954 int frame_count = stack_trace->GetFrameCount();
16955 CHECK_EQ(3, frame_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (frame_count
), "3" " " "==" " " "frame_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 16955, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
16956 int line_number[] = {1, 2, 5};
16957 for (int i = 0; i < frame_count; i++) {
16958 CHECK_EQ(line_number[i], stack_trace->GetFrame(i)->GetLineNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (line_number
[i]), (stack_trace->GetFrame(i)->GetLineNumber()), "line_number[i]"
" " "==" " " "stack_trace->GetFrame(i)->GetLineNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 16958, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
16959 }
16960}
16961
16962
16963// Test that we only return the stack trace at the site where the exception
16964// is first thrown (not where it is rethrown).
16965TEST(RethrowStackTrace)static void TestRethrowStackTrace(); CcTest register_test_RethrowStackTrace
(TestRethrowStackTrace, "../test/cctest/test-api.cc", "RethrowStackTrace"
, __null, true, true); static void TestRethrowStackTrace()
{
16966 LocalContext env;
16967 v8::Isolate* isolate = env->GetIsolate();
16968 v8::HandleScope scope(isolate);
16969 // We make sure that
16970 // - the stack trace of the ReferenceError in g() is reported.
16971 // - the stack trace is not overwritten when e1 is rethrown by t().
16972 // - the stack trace of e2 does not overwrite that of e1.
16973 const char* source =
16974 "function g() { error; } \n"
16975 "function f() { g(); } \n"
16976 "function t(e) { throw e; } \n"
16977 "try { \n"
16978 " f(); \n"
16979 "} catch (e1) { \n"
16980 " try { \n"
16981 " error; \n"
16982 " } catch (e2) { \n"
16983 " t(e1); \n"
16984 " } \n"
16985 "} \n";
16986 isolate->AddMessageListener(RethrowStackTraceHandler);
16987 isolate->SetCaptureStackTraceForUncaughtExceptions(true);
16988 CompileRun(source);
16989 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
16990 isolate->RemoveMessageListeners(RethrowStackTraceHandler);
16991}
16992
16993
16994static void RethrowPrimitiveStackTraceHandler(v8::Local<v8::Message> message,
16995 v8::Local<v8::Value> data) {
16996 v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
16997 CHECK(!stack_trace.IsEmpty())do { if ((__builtin_expect(!!(!(!stack_trace.IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 16997, "Check failed: %s."
, "!stack_trace.IsEmpty()"); } } while (0)
;
16998 int frame_count = stack_trace->GetFrameCount();
16999 CHECK_EQ(2, frame_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (frame_count
), "2" " " "==" " " "frame_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 16999, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17000 int line_number[] = {3, 7};
17001 for (int i = 0; i < frame_count; i++) {
17002 CHECK_EQ(line_number[i], stack_trace->GetFrame(i)->GetLineNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (line_number
[i]), (stack_trace->GetFrame(i)->GetLineNumber()), "line_number[i]"
" " "==" " " "stack_trace->GetFrame(i)->GetLineNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17002, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17003 }
17004}
17005
17006
17007// Test that we do not recognize identity for primitive exceptions.
17008TEST(RethrowPrimitiveStackTrace)static void TestRethrowPrimitiveStackTrace(); CcTest register_test_RethrowPrimitiveStackTrace
(TestRethrowPrimitiveStackTrace, "../test/cctest/test-api.cc"
, "RethrowPrimitiveStackTrace", __null, true, true); static void
TestRethrowPrimitiveStackTrace()
{
17009 LocalContext env;
17010 v8::Isolate* isolate = env->GetIsolate();
17011 v8::HandleScope scope(isolate);
17012 // We do not capture stack trace for non Error objects on creation time.
17013 // Instead, we capture the stack trace on last throw.
17014 const char* source =
17015 "function g() { throw 404; } \n"
17016 "function f() { g(); } \n"
17017 "function t(e) { throw e; } \n"
17018 "try { \n"
17019 " f(); \n"
17020 "} catch (e1) { \n"
17021 " t(e1) \n"
17022 "} \n";
17023 isolate->AddMessageListener(RethrowPrimitiveStackTraceHandler);
17024 isolate->SetCaptureStackTraceForUncaughtExceptions(true);
17025 CompileRun(source);
17026 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
17027 isolate->RemoveMessageListeners(RethrowPrimitiveStackTraceHandler);
17028}
17029
17030
17031static void RethrowExistingStackTraceHandler(v8::Local<v8::Message> message,
17032 v8::Local<v8::Value> data) {
17033 // Use the frame where JavaScript is called from.
17034 v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
17035 CHECK(!stack_trace.IsEmpty())do { if ((__builtin_expect(!!(!(!stack_trace.IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 17035, "Check failed: %s."
, "!stack_trace.IsEmpty()"); } } while (0)
;
17036 CHECK_EQ(1, stack_trace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (stack_trace
->GetFrameCount()), "1" " " "==" " " "stack_trace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17036, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17037 CHECK_EQ(1, stack_trace->GetFrame(0)->GetLineNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (stack_trace
->GetFrame(0)->GetLineNumber()), "1" " " "==" " " "stack_trace->GetFrame(0)->GetLineNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17037, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17038}
17039
17040
17041// Test that the stack trace is captured when the error object is created and
17042// not where it is thrown.
17043TEST(RethrowExistingStackTrace)static void TestRethrowExistingStackTrace(); CcTest register_test_RethrowExistingStackTrace
(TestRethrowExistingStackTrace, "../test/cctest/test-api.cc",
"RethrowExistingStackTrace", __null, true, true); static void
TestRethrowExistingStackTrace()
{
17044 LocalContext env;
17045 v8::Isolate* isolate = env->GetIsolate();
17046 v8::HandleScope scope(isolate);
17047 const char* source =
17048 "var e = new Error(); \n"
17049 "throw e; \n";
17050 isolate->AddMessageListener(RethrowExistingStackTraceHandler);
17051 isolate->SetCaptureStackTraceForUncaughtExceptions(true);
17052 CompileRun(source);
17053 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
17054 isolate->RemoveMessageListeners(RethrowExistingStackTraceHandler);
17055}
17056
17057
17058static void RethrowBogusErrorStackTraceHandler(v8::Local<v8::Message> message,
17059 v8::Local<v8::Value> data) {
17060 // Use the frame where JavaScript is called from.
17061 v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
17062 CHECK(!stack_trace.IsEmpty())do { if ((__builtin_expect(!!(!(!stack_trace.IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 17062, "Check failed: %s."
, "!stack_trace.IsEmpty()"); } } while (0)
;
17063 CHECK_EQ(1, stack_trace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (stack_trace
->GetFrameCount()), "1" " " "==" " " "stack_trace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17063, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17064 CHECK_EQ(2, stack_trace->GetFrame(0)->GetLineNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (stack_trace
->GetFrame(0)->GetLineNumber()), "2" " " "==" " " "stack_trace->GetFrame(0)->GetLineNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17064, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17065}
17066
17067
17068// Test that the stack trace is captured where the bogus Error object is thrown.
17069TEST(RethrowBogusErrorStackTrace)static void TestRethrowBogusErrorStackTrace(); CcTest register_test_RethrowBogusErrorStackTrace
(TestRethrowBogusErrorStackTrace, "../test/cctest/test-api.cc"
, "RethrowBogusErrorStackTrace", __null, true, true); static void
TestRethrowBogusErrorStackTrace()
{
17070 LocalContext env;
17071 v8::Isolate* isolate = env->GetIsolate();
17072 v8::HandleScope scope(isolate);
17073 const char* source =
17074 "var e = {__proto__: new Error()} \n"
17075 "throw e; \n";
17076 isolate->AddMessageListener(RethrowBogusErrorStackTraceHandler);
17077 isolate->SetCaptureStackTraceForUncaughtExceptions(true);
17078 CompileRun(source);
17079 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
17080 isolate->RemoveMessageListeners(RethrowBogusErrorStackTraceHandler);
17081}
17082
17083
17084v8::PromiseRejectEvent reject_event = v8::kPromiseRejectWithNoHandler;
17085int promise_reject_counter = 0;
17086int promise_revoke_counter = 0;
17087int promise_reject_msg_line_number = -1;
17088int promise_reject_msg_column_number = -1;
17089int promise_reject_line_number = -1;
17090int promise_reject_column_number = -1;
17091int promise_reject_frame_count = -1;
17092
17093void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) {
17094 v8::Local<v8::Object> global = CcTest::global();
17095 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
17096 if (reject_message.GetEvent() == v8::kPromiseRejectWithNoHandler) {
17097 promise_reject_counter++;
17098 global->Set(context, v8_str("rejected"), reject_message.GetPromise())
17099 .FromJust();
17100 global->Set(context, v8_str("value"), reject_message.GetValue()).FromJust();
17101 v8::Local<v8::Message> message = v8::Exception::CreateMessage(
17102 CcTest::isolate(), reject_message.GetValue());
17103 v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace();
17104
17105 promise_reject_msg_line_number = message->GetLineNumber(context).FromJust();
17106 promise_reject_msg_column_number =
17107 message->GetStartColumn(context).FromJust() + 1;
17108
17109 if (!stack_trace.IsEmpty()) {
17110 promise_reject_frame_count = stack_trace->GetFrameCount();
17111 if (promise_reject_frame_count > 0) {
17112 CHECK(stack_trace->GetFrame(0)do { if ((__builtin_expect(!!(!(stack_trace->GetFrame(0) ->
GetScriptName() ->Equals(context, v8_str("pro")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17115, "Check failed: %s."
, "stack_trace->GetFrame(0) ->GetScriptName() ->Equals(context, v8_str(\"pro\")) .FromJust()"
); } } while (0)
17113 ->GetScriptName()do { if ((__builtin_expect(!!(!(stack_trace->GetFrame(0) ->
GetScriptName() ->Equals(context, v8_str("pro")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17115, "Check failed: %s."
, "stack_trace->GetFrame(0) ->GetScriptName() ->Equals(context, v8_str(\"pro\")) .FromJust()"
); } } while (0)
17114 ->Equals(context, v8_str("pro"))do { if ((__builtin_expect(!!(!(stack_trace->GetFrame(0) ->
GetScriptName() ->Equals(context, v8_str("pro")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17115, "Check failed: %s."
, "stack_trace->GetFrame(0) ->GetScriptName() ->Equals(context, v8_str(\"pro\")) .FromJust()"
); } } while (0)
17115 .FromJust())do { if ((__builtin_expect(!!(!(stack_trace->GetFrame(0) ->
GetScriptName() ->Equals(context, v8_str("pro")) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17115, "Check failed: %s."
, "stack_trace->GetFrame(0) ->GetScriptName() ->Equals(context, v8_str(\"pro\")) .FromJust()"
); } } while (0)
;
17116 promise_reject_line_number = stack_trace->GetFrame(0)->GetLineNumber();
17117 promise_reject_column_number = stack_trace->GetFrame(0)->GetColumn();
17118 } else {
17119 promise_reject_line_number = -1;
17120 promise_reject_column_number = -1;
17121 }
17122 }
17123 } else {
17124 promise_revoke_counter++;
17125 global->Set(context, v8_str("revoked"), reject_message.GetPromise())
17126 .FromJust();
17127 CHECK(reject_message.GetValue().IsEmpty())do { if ((__builtin_expect(!!(!(reject_message.GetValue().IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17127, "Check failed: %s."
, "reject_message.GetValue().IsEmpty()"); } } while (0)
;
17128 }
17129}
17130
17131
17132v8::Local<v8::Promise> GetPromise(const char* name) {
17133 return v8::Local<v8::Promise>::Cast(
17134 CcTest::global()
17135 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str(name))
17136 .ToLocalChecked());
17137}
17138
17139
17140v8::Local<v8::Value> RejectValue() {
17141 return CcTest::global()
17142 ->Get(CcTest::isolate()->GetCurrentContext(), v8_str("value"))
17143 .ToLocalChecked();
17144}
17145
17146
17147void ResetPromiseStates() {
17148 promise_reject_counter = 0;
17149 promise_revoke_counter = 0;
17150 promise_reject_msg_line_number = -1;
17151 promise_reject_msg_column_number = -1;
17152 promise_reject_line_number = -1;
17153 promise_reject_column_number = -1;
17154 promise_reject_frame_count = -1;
17155
17156 v8::Local<v8::Object> global = CcTest::global();
17157 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
17158 global->Set(context, v8_str("rejected"), v8_str("")).FromJust();
17159 global->Set(context, v8_str("value"), v8_str("")).FromJust();
17160 global->Set(context, v8_str("revoked"), v8_str("")).FromJust();
17161}
17162
17163
17164TEST(PromiseRejectCallback)static void TestPromiseRejectCallback(); CcTest register_test_PromiseRejectCallback
(TestPromiseRejectCallback, "../test/cctest/test-api.cc", "PromiseRejectCallback"
, __null, true, true); static void TestPromiseRejectCallback(
)
{
17165 LocalContext env;
17166 v8::Isolate* isolate = env->GetIsolate();
17167 v8::HandleScope scope(isolate);
17168
17169 isolate->SetPromiseRejectCallback(PromiseRejectCallback);
17170
17171 ResetPromiseStates();
17172
17173 // Create promise p0.
17174 CompileRun(
17175 "var reject; \n"
17176 "var p0 = new Promise( \n"
17177 " function(res, rej) { \n"
17178 " reject = rej; \n"
17179 " } \n"
17180 "); \n");
17181 CHECK(!GetPromise("p0")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("p0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17181, "Check failed: %s."
, "!GetPromise(\"p0\")->HasHandler()"); } } while (0)
;
17182 CHECK_EQ(0, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_reject_counter
), "0" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17182, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17183 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17183, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17184
17185 // Add resolve handler (and default reject handler) to p0.
17186 CompileRun("var p1 = p0.then(function(){});");
17187 CHECK(GetPromise("p0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("p0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17187, "Check failed: %s."
, "GetPromise(\"p0\")->HasHandler()"); } } while (0)
;
17188 CHECK(!GetPromise("p1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("p1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17188, "Check failed: %s."
, "!GetPromise(\"p1\")->HasHandler()"); } } while (0)
;
17189 CHECK_EQ(0, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_reject_counter
), "0" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17189, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17190 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17190, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17191
17192 // Reject p0.
17193 CompileRun("reject('ppp');");
17194 CHECK(GetPromise("p0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("p0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17194, "Check failed: %s."
, "GetPromise(\"p0\")->HasHandler()"); } } while (0)
;
17195 CHECK(!GetPromise("p1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("p1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17195, "Check failed: %s."
, "!GetPromise(\"p1\")->HasHandler()"); } } while (0)
;
17196 CHECK_EQ(1, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_reject_counter
), "1" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17196, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17197 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17197, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17198 CHECK_EQ(v8::kPromiseRejectWithNoHandler, reject_event)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::kPromiseRejectWithNoHandler
), (reject_event), "v8::kPromiseRejectWithNoHandler" " " "=="
" " "reject_event")) { V8_Fatal("../test/cctest/test-api.cc"
, 17198, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17199 CHECK(do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("p1")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17200, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"p1\")).FromJust()"
); } } while (0)
17200 GetPromise("rejected")->Equals(env.local(), GetPromise("p1")).FromJust())do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("p1")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17200, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"p1\")).FromJust()"
); } } while (0)
;
17201 CHECK(RejectValue()->Equals(env.local(), v8_str("ppp")).FromJust())do { if ((__builtin_expect(!!(!(RejectValue()->Equals(env.
local(), v8_str("ppp")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17201, "Check failed: %s.", "RejectValue()->Equals(env.local(), v8_str(\"ppp\")).FromJust()"
); } } while (0)
;
17202
17203 // Reject p0 again. Callback is not triggered again.
17204 CompileRun("reject();");
17205 CHECK(GetPromise("p0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("p0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17205, "Check failed: %s."
, "GetPromise(\"p0\")->HasHandler()"); } } while (0)
;
17206 CHECK(!GetPromise("p1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("p1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17206, "Check failed: %s."
, "!GetPromise(\"p1\")->HasHandler()"); } } while (0)
;
17207 CHECK_EQ(1, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_reject_counter
), "1" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17207, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17208 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17208, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17209
17210 // Add resolve handler to p1.
17211 CompileRun("var p2 = p1.then(function(){});");
17212 CHECK(GetPromise("p0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("p0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17212, "Check failed: %s."
, "GetPromise(\"p0\")->HasHandler()"); } } while (0)
;
17213 CHECK(GetPromise("p1")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("p1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17213, "Check failed: %s."
, "GetPromise(\"p1\")->HasHandler()"); } } while (0)
;
17214 CHECK(!GetPromise("p2")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("p2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17214, "Check failed: %s."
, "!GetPromise(\"p2\")->HasHandler()"); } } while (0)
;
17215 CHECK_EQ(2, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (promise_reject_counter
), "2" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17215, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17216 CHECK_EQ(1, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_revoke_counter
), "1" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17216, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17217 CHECK(do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("p2")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17218, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"p2\")).FromJust()"
); } } while (0)
17218 GetPromise("rejected")->Equals(env.local(), GetPromise("p2")).FromJust())do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("p2")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17218, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"p2\")).FromJust()"
); } } while (0)
;
17219 CHECK(RejectValue()->Equals(env.local(), v8_str("ppp")).FromJust())do { if ((__builtin_expect(!!(!(RejectValue()->Equals(env.
local(), v8_str("ppp")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17219, "Check failed: %s.", "RejectValue()->Equals(env.local(), v8_str(\"ppp\")).FromJust()"
); } } while (0)
;
17220 CHECK(do { if ((__builtin_expect(!!(!(GetPromise("revoked")->Equals
(env.local(), GetPromise("p1")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17221, "Check failed: %s.", "GetPromise(\"revoked\")->Equals(env.local(), GetPromise(\"p1\")).FromJust()"
); } } while (0)
17221 GetPromise("revoked")->Equals(env.local(), GetPromise("p1")).FromJust())do { if ((__builtin_expect(!!(!(GetPromise("revoked")->Equals
(env.local(), GetPromise("p1")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17221, "Check failed: %s.", "GetPromise(\"revoked\")->Equals(env.local(), GetPromise(\"p1\")).FromJust()"
); } } while (0)
;
17222
17223 ResetPromiseStates();
17224
17225 // Create promise q0.
17226 CompileRun(
17227 "var q0 = new Promise( \n"
17228 " function(res, rej) { \n"
17229 " reject = rej; \n"
17230 " } \n"
17231 "); \n");
17232 CHECK(!GetPromise("q0")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("q0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17232, "Check failed: %s."
, "!GetPromise(\"q0\")->HasHandler()"); } } while (0)
;
17233 CHECK_EQ(0, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_reject_counter
), "0" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17233, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17234 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17234, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17235
17236 // Add reject handler to q0.
17237 CompileRun("var q1 = q0.catch(function() {});");
17238 CHECK(GetPromise("q0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("q0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17238, "Check failed: %s."
, "GetPromise(\"q0\")->HasHandler()"); } } while (0)
;
17239 CHECK(!GetPromise("q1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("q1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17239, "Check failed: %s."
, "!GetPromise(\"q1\")->HasHandler()"); } } while (0)
;
17240 CHECK_EQ(0, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_reject_counter
), "0" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17240, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17241 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17241, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17242
17243 // Reject q0.
17244 CompileRun("reject('qq')");
17245 CHECK(GetPromise("q0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("q0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17245, "Check failed: %s."
, "GetPromise(\"q0\")->HasHandler()"); } } while (0)
;
17246 CHECK(!GetPromise("q1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("q1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17246, "Check failed: %s."
, "!GetPromise(\"q1\")->HasHandler()"); } } while (0)
;
17247 CHECK_EQ(0, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_reject_counter
), "0" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17247, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17248 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17248, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17249
17250 // Add a new reject handler, which rejects by returning Promise.reject().
17251 // The returned promise q_ triggers a reject callback at first, only to
17252 // revoke it when returning it causes q2 to be rejected.
17253 CompileRun(
17254 "var q_;"
17255 "var q2 = q0.catch( \n"
17256 " function() { \n"
17257 " q_ = Promise.reject('qqq'); \n"
17258 " return q_; \n"
17259 " } \n"
17260 "); \n");
17261 CHECK(GetPromise("q0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("q0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17261, "Check failed: %s."
, "GetPromise(\"q0\")->HasHandler()"); } } while (0)
;
17262 CHECK(!GetPromise("q1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("q1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17262, "Check failed: %s."
, "!GetPromise(\"q1\")->HasHandler()"); } } while (0)
;
17263 CHECK(!GetPromise("q2")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("q2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17263, "Check failed: %s."
, "!GetPromise(\"q2\")->HasHandler()"); } } while (0)
;
17264 CHECK(GetPromise("q_")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("q_")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17264, "Check failed: %s."
, "GetPromise(\"q_\")->HasHandler()"); } } while (0)
;
17265 CHECK_EQ(2, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (promise_reject_counter
), "2" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17265, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17266 CHECK_EQ(1, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_revoke_counter
), "1" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17266, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17267 CHECK(do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("q2")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17268, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"q2\")).FromJust()"
); } } while (0)
17268 GetPromise("rejected")->Equals(env.local(), GetPromise("q2")).FromJust())do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("q2")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17268, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"q2\")).FromJust()"
); } } while (0)
;
17269 CHECK(do { if ((__builtin_expect(!!(!(GetPromise("revoked")->Equals
(env.local(), GetPromise("q_")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17270, "Check failed: %s.", "GetPromise(\"revoked\")->Equals(env.local(), GetPromise(\"q_\")).FromJust()"
); } } while (0)
17270 GetPromise("revoked")->Equals(env.local(), GetPromise("q_")).FromJust())do { if ((__builtin_expect(!!(!(GetPromise("revoked")->Equals
(env.local(), GetPromise("q_")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17270, "Check failed: %s.", "GetPromise(\"revoked\")->Equals(env.local(), GetPromise(\"q_\")).FromJust()"
); } } while (0)
;
17271 CHECK(RejectValue()->Equals(env.local(), v8_str("qqq")).FromJust())do { if ((__builtin_expect(!!(!(RejectValue()->Equals(env.
local(), v8_str("qqq")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17271, "Check failed: %s.", "RejectValue()->Equals(env.local(), v8_str(\"qqq\")).FromJust()"
); } } while (0)
;
17272
17273 // Add a reject handler to the resolved q1, which rejects by throwing.
17274 CompileRun(
17275 "var q3 = q1.then( \n"
17276 " function() { \n"
17277 " throw 'qqqq'; \n"
17278 " } \n"
17279 "); \n");
17280 CHECK(GetPromise("q0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("q0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17280, "Check failed: %s."
, "GetPromise(\"q0\")->HasHandler()"); } } while (0)
;
17281 CHECK(GetPromise("q1")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("q1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17281, "Check failed: %s."
, "GetPromise(\"q1\")->HasHandler()"); } } while (0)
;
17282 CHECK(!GetPromise("q2")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("q2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17282, "Check failed: %s."
, "!GetPromise(\"q2\")->HasHandler()"); } } while (0)
;
17283 CHECK(!GetPromise("q3")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("q3")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17283, "Check failed: %s."
, "!GetPromise(\"q3\")->HasHandler()"); } } while (0)
;
17284 CHECK_EQ(3, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (promise_reject_counter
), "3" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17284, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17285 CHECK_EQ(1, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_revoke_counter
), "1" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17285, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17286 CHECK(do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("q3")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17287, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"q3\")).FromJust()"
); } } while (0)
17287 GetPromise("rejected")->Equals(env.local(), GetPromise("q3")).FromJust())do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("q3")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17287, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"q3\")).FromJust()"
); } } while (0)
;
17288 CHECK(RejectValue()->Equals(env.local(), v8_str("qqqq")).FromJust())do { if ((__builtin_expect(!!(!(RejectValue()->Equals(env.
local(), v8_str("qqqq")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17288, "Check failed: %s.", "RejectValue()->Equals(env.local(), v8_str(\"qqqq\")).FromJust()"
); } } while (0)
;
17289
17290 ResetPromiseStates();
17291
17292 // Create promise r0, which has three handlers, two of which handle rejects.
17293 CompileRun(
17294 "var r0 = new Promise( \n"
17295 " function(res, rej) { \n"
17296 " reject = rej; \n"
17297 " } \n"
17298 "); \n"
17299 "var r1 = r0.catch(function() {}); \n"
17300 "var r2 = r0.then(function() {}); \n"
17301 "var r3 = r0.then(function() {}, \n"
17302 " function() {}); \n");
17303 CHECK(GetPromise("r0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("r0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17303, "Check failed: %s."
, "GetPromise(\"r0\")->HasHandler()"); } } while (0)
;
17304 CHECK(!GetPromise("r1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17304, "Check failed: %s."
, "!GetPromise(\"r1\")->HasHandler()"); } } while (0)
;
17305 CHECK(!GetPromise("r2")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17305, "Check failed: %s."
, "!GetPromise(\"r2\")->HasHandler()"); } } while (0)
;
17306 CHECK(!GetPromise("r3")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r3")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17306, "Check failed: %s."
, "!GetPromise(\"r3\")->HasHandler()"); } } while (0)
;
17307 CHECK_EQ(0, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_reject_counter
), "0" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17307, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17308 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17308, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17309
17310 // Reject r0.
17311 CompileRun("reject('rrr')");
17312 CHECK(GetPromise("r0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("r0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17312, "Check failed: %s."
, "GetPromise(\"r0\")->HasHandler()"); } } while (0)
;
17313 CHECK(!GetPromise("r1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17313, "Check failed: %s."
, "!GetPromise(\"r1\")->HasHandler()"); } } while (0)
;
17314 CHECK(!GetPromise("r2")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17314, "Check failed: %s."
, "!GetPromise(\"r2\")->HasHandler()"); } } while (0)
;
17315 CHECK(!GetPromise("r3")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r3")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17315, "Check failed: %s."
, "!GetPromise(\"r3\")->HasHandler()"); } } while (0)
;
17316 CHECK_EQ(1, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_reject_counter
), "1" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17316, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17317 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17317, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17318 CHECK(do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("r2")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17319, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"r2\")).FromJust()"
); } } while (0)
17319 GetPromise("rejected")->Equals(env.local(), GetPromise("r2")).FromJust())do { if ((__builtin_expect(!!(!(GetPromise("rejected")->Equals
(env.local(), GetPromise("r2")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17319, "Check failed: %s.", "GetPromise(\"rejected\")->Equals(env.local(), GetPromise(\"r2\")).FromJust()"
); } } while (0)
;
17320 CHECK(RejectValue()->Equals(env.local(), v8_str("rrr")).FromJust())do { if ((__builtin_expect(!!(!(RejectValue()->Equals(env.
local(), v8_str("rrr")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17320, "Check failed: %s.", "RejectValue()->Equals(env.local(), v8_str(\"rrr\")).FromJust()"
); } } while (0)
;
17321
17322 // Add reject handler to r2.
17323 CompileRun("var r4 = r2.catch(function() {});");
17324 CHECK(GetPromise("r0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("r0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17324, "Check failed: %s."
, "GetPromise(\"r0\")->HasHandler()"); } } while (0)
;
17325 CHECK(!GetPromise("r1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17325, "Check failed: %s."
, "!GetPromise(\"r1\")->HasHandler()"); } } while (0)
;
17326 CHECK(GetPromise("r2")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("r2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17326, "Check failed: %s."
, "GetPromise(\"r2\")->HasHandler()"); } } while (0)
;
17327 CHECK(!GetPromise("r3")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r3")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17327, "Check failed: %s."
, "!GetPromise(\"r3\")->HasHandler()"); } } while (0)
;
17328 CHECK(!GetPromise("r4")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r4")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17328, "Check failed: %s."
, "!GetPromise(\"r4\")->HasHandler()"); } } while (0)
;
17329 CHECK_EQ(1, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_reject_counter
), "1" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17329, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17330 CHECK_EQ(1, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_revoke_counter
), "1" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17330, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17331 CHECK(do { if ((__builtin_expect(!!(!(GetPromise("revoked")->Equals
(env.local(), GetPromise("r2")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17332, "Check failed: %s.", "GetPromise(\"revoked\")->Equals(env.local(), GetPromise(\"r2\")).FromJust()"
); } } while (0)
17332 GetPromise("revoked")->Equals(env.local(), GetPromise("r2")).FromJust())do { if ((__builtin_expect(!!(!(GetPromise("revoked")->Equals
(env.local(), GetPromise("r2")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17332, "Check failed: %s.", "GetPromise(\"revoked\")->Equals(env.local(), GetPromise(\"r2\")).FromJust()"
); } } while (0)
;
17333 CHECK(RejectValue()->Equals(env.local(), v8_str("rrr")).FromJust())do { if ((__builtin_expect(!!(!(RejectValue()->Equals(env.
local(), v8_str("rrr")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17333, "Check failed: %s.", "RejectValue()->Equals(env.local(), v8_str(\"rrr\")).FromJust()"
); } } while (0)
;
17334
17335 // Add reject handlers to r4.
17336 CompileRun("var r5 = r4.then(function() {}, function() {});");
17337 CHECK(GetPromise("r0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("r0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17337, "Check failed: %s."
, "GetPromise(\"r0\")->HasHandler()"); } } while (0)
;
17338 CHECK(!GetPromise("r1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17338, "Check failed: %s."
, "!GetPromise(\"r1\")->HasHandler()"); } } while (0)
;
17339 CHECK(GetPromise("r2")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("r2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17339, "Check failed: %s."
, "GetPromise(\"r2\")->HasHandler()"); } } while (0)
;
17340 CHECK(!GetPromise("r3")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r3")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17340, "Check failed: %s."
, "!GetPromise(\"r3\")->HasHandler()"); } } while (0)
;
17341 CHECK(GetPromise("r4")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("r4")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17341, "Check failed: %s."
, "GetPromise(\"r4\")->HasHandler()"); } } while (0)
;
17342 CHECK(!GetPromise("r5")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("r5")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17342, "Check failed: %s."
, "!GetPromise(\"r5\")->HasHandler()"); } } while (0)
;
17343 CHECK_EQ(1, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_reject_counter
), "1" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17343, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17344 CHECK_EQ(1, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_revoke_counter
), "1" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17344, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17345
17346 ResetPromiseStates();
17347
17348 // Create promise s0, which has three handlers, none of which handle rejects.
17349 CompileRun(
17350 "var s0 = new Promise( \n"
17351 " function(res, rej) { \n"
17352 " reject = rej; \n"
17353 " } \n"
17354 "); \n"
17355 "var s1 = s0.then(function() {}); \n"
17356 "var s2 = s0.then(function() {}); \n"
17357 "var s3 = s0.then(function() {}); \n");
17358 CHECK(GetPromise("s0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("s0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17358, "Check failed: %s."
, "GetPromise(\"s0\")->HasHandler()"); } } while (0)
;
17359 CHECK(!GetPromise("s1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("s1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17359, "Check failed: %s."
, "!GetPromise(\"s1\")->HasHandler()"); } } while (0)
;
17360 CHECK(!GetPromise("s2")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("s2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17360, "Check failed: %s."
, "!GetPromise(\"s2\")->HasHandler()"); } } while (0)
;
17361 CHECK(!GetPromise("s3")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("s3")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17361, "Check failed: %s."
, "!GetPromise(\"s3\")->HasHandler()"); } } while (0)
;
17362 CHECK_EQ(0, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_reject_counter
), "0" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17362, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17363 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17363, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17364
17365 // Reject s0.
17366 CompileRun("reject('sss')");
17367 CHECK(GetPromise("s0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("s0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17367, "Check failed: %s."
, "GetPromise(\"s0\")->HasHandler()"); } } while (0)
;
17368 CHECK(!GetPromise("s1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("s1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17368, "Check failed: %s."
, "!GetPromise(\"s1\")->HasHandler()"); } } while (0)
;
17369 CHECK(!GetPromise("s2")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("s2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17369, "Check failed: %s."
, "!GetPromise(\"s2\")->HasHandler()"); } } while (0)
;
17370 CHECK(!GetPromise("s3")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("s3")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17370, "Check failed: %s."
, "!GetPromise(\"s3\")->HasHandler()"); } } while (0)
;
17371 CHECK_EQ(3, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (promise_reject_counter
), "3" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17371, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17372 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17372, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17373 CHECK(RejectValue()->Equals(env.local(), v8_str("sss")).FromJust())do { if ((__builtin_expect(!!(!(RejectValue()->Equals(env.
local(), v8_str("sss")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17373, "Check failed: %s.", "RejectValue()->Equals(env.local(), v8_str(\"sss\")).FromJust()"
); } } while (0)
;
17374
17375 // Test stack frames.
17376 env->GetIsolate()->SetCaptureStackTraceForUncaughtExceptions(true);
17377
17378 ResetPromiseStates();
17379
17380 // Create promise t0, which is rejected in the constructor with an error.
17381 CompileRunWithOrigin(
17382 "var t0 = new Promise( \n"
17383 " function(res, rej) { \n"
17384 " reference_error; \n"
17385 " } \n"
17386 "); \n",
17387 "pro", 0, 0);
17388 CHECK(!GetPromise("t0")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("t0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17388, "Check failed: %s."
, "!GetPromise(\"t0\")->HasHandler()"); } } while (0)
;
17389 CHECK_EQ(1, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_reject_counter
), "1" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17389, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17390 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17390, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17391 CHECK_EQ(2, promise_reject_frame_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (promise_reject_frame_count
), "2" " " "==" " " "promise_reject_frame_count")) { V8_Fatal
("../test/cctest/test-api.cc", 17391, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17392 CHECK_EQ(3, promise_reject_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (promise_reject_line_number
), "3" " " "==" " " "promise_reject_line_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17392, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17393 CHECK_EQ(5, promise_reject_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (promise_reject_column_number
), "5" " " "==" " " "promise_reject_column_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17393, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17394 CHECK_EQ(3, promise_reject_msg_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (promise_reject_msg_line_number
), "3" " " "==" " " "promise_reject_msg_line_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17394, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17395 CHECK_EQ(5, promise_reject_msg_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (promise_reject_msg_column_number
), "5" " " "==" " " "promise_reject_msg_column_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17395, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17396
17397 ResetPromiseStates();
17398
17399 // Create promise u0 and chain u1 to it, which is rejected via throw.
17400 CompileRunWithOrigin(
17401 "var u0 = Promise.resolve(); \n"
17402 "var u1 = u0.then( \n"
17403 " function() { \n"
17404 " (function() { \n"
17405 " throw new Error(); \n"
17406 " })(); \n"
17407 " } \n"
17408 " ); \n",
17409 "pro", 0, 0);
17410 CHECK(GetPromise("u0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("u0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17410, "Check failed: %s."
, "GetPromise(\"u0\")->HasHandler()"); } } while (0)
;
17411 CHECK(!GetPromise("u1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("u1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17411, "Check failed: %s."
, "!GetPromise(\"u1\")->HasHandler()"); } } while (0)
;
17412 CHECK_EQ(1, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_reject_counter
), "1" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17412, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17413 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17413, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17414 CHECK_EQ(2, promise_reject_frame_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (promise_reject_frame_count
), "2" " " "==" " " "promise_reject_frame_count")) { V8_Fatal
("../test/cctest/test-api.cc", 17414, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17415 CHECK_EQ(5, promise_reject_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (promise_reject_line_number
), "5" " " "==" " " "promise_reject_line_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17415, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17416 CHECK_EQ(23, promise_reject_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
promise_reject_column_number), "23" " " "==" " " "promise_reject_column_number"
)) { V8_Fatal("../test/cctest/test-api.cc", 17416, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17417 CHECK_EQ(5, promise_reject_msg_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (promise_reject_msg_line_number
), "5" " " "==" " " "promise_reject_msg_line_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17417, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17418 CHECK_EQ(23, promise_reject_msg_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
promise_reject_msg_column_number), "23" " " "==" " " "promise_reject_msg_column_number"
)) { V8_Fatal("../test/cctest/test-api.cc", 17418, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17419
17420 // Throw in u3, which handles u1's rejection.
17421 CompileRunWithOrigin(
17422 "function f() { \n"
17423 " return (function() { \n"
17424 " return new Error(); \n"
17425 " })(); \n"
17426 "} \n"
17427 "var u2 = Promise.reject(f()); \n"
17428 "var u3 = u1.catch( \n"
17429 " function() { \n"
17430 " return u2; \n"
17431 " } \n"
17432 " ); \n",
17433 "pro", 0, 0);
17434 CHECK(GetPromise("u0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("u0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17434, "Check failed: %s."
, "GetPromise(\"u0\")->HasHandler()"); } } while (0)
;
17435 CHECK(GetPromise("u1")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("u1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17435, "Check failed: %s."
, "GetPromise(\"u1\")->HasHandler()"); } } while (0)
;
17436 CHECK(GetPromise("u2")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("u2")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17436, "Check failed: %s."
, "GetPromise(\"u2\")->HasHandler()"); } } while (0)
;
17437 CHECK(!GetPromise("u3")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("u3")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17437, "Check failed: %s."
, "!GetPromise(\"u3\")->HasHandler()"); } } while (0)
;
17438 CHECK_EQ(3, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (promise_reject_counter
), "3" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17438, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17439 CHECK_EQ(2, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (promise_revoke_counter
), "2" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17439, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17440 CHECK_EQ(3, promise_reject_frame_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (promise_reject_frame_count
), "3" " " "==" " " "promise_reject_frame_count")) { V8_Fatal
("../test/cctest/test-api.cc", 17440, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17441 CHECK_EQ(3, promise_reject_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (promise_reject_line_number
), "3" " " "==" " " "promise_reject_line_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17441, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17442 CHECK_EQ(12, promise_reject_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
promise_reject_column_number), "12" " " "==" " " "promise_reject_column_number"
)) { V8_Fatal("../test/cctest/test-api.cc", 17442, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17443 CHECK_EQ(3, promise_reject_msg_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (promise_reject_msg_line_number
), "3" " " "==" " " "promise_reject_msg_line_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17443, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17444 CHECK_EQ(12, promise_reject_msg_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (12), (
promise_reject_msg_column_number), "12" " " "==" " " "promise_reject_msg_column_number"
)) { V8_Fatal("../test/cctest/test-api.cc", 17444, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17445
17446 ResetPromiseStates();
17447
17448 // Create promise rejected promise v0, which is incorrectly handled by v1
17449 // via chaining cycle.
17450 CompileRunWithOrigin(
17451 "var v0 = Promise.reject(); \n"
17452 "var v1 = v0.catch( \n"
17453 " function() { \n"
17454 " return v1; \n"
17455 " } \n"
17456 " ); \n",
17457 "pro", 0, 0);
17458 CHECK(GetPromise("v0")->HasHandler())do { if ((__builtin_expect(!!(!(GetPromise("v0")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17458, "Check failed: %s."
, "GetPromise(\"v0\")->HasHandler()"); } } while (0)
;
17459 CHECK(!GetPromise("v1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("v1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17459, "Check failed: %s."
, "!GetPromise(\"v1\")->HasHandler()"); } } while (0)
;
17460 CHECK_EQ(2, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (promise_reject_counter
), "2" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17460, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17461 CHECK_EQ(1, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_revoke_counter
), "1" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17461, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17462 CHECK_EQ(0, promise_reject_frame_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_reject_frame_count
), "0" " " "==" " " "promise_reject_frame_count")) { V8_Fatal
("../test/cctest/test-api.cc", 17462, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17463 CHECK_EQ(-1, promise_reject_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-1), (
promise_reject_line_number), "-1" " " "==" " " "promise_reject_line_number"
)) { V8_Fatal("../test/cctest/test-api.cc", 17463, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17464 CHECK_EQ(-1, promise_reject_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (-1), (
promise_reject_column_number), "-1" " " "==" " " "promise_reject_column_number"
)) { V8_Fatal("../test/cctest/test-api.cc", 17464, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17465
17466 ResetPromiseStates();
17467
17468 // Create promise t1, which rejects by throwing syntax error from eval.
17469 CompileRunWithOrigin(
17470 "var t1 = new Promise( \n"
17471 " function(res, rej) { \n"
17472 " var content = '\\n\\\n"
17473 " }'; \n"
17474 " eval(content); \n"
17475 " } \n"
17476 "); \n",
17477 "pro", 0, 0);
17478 CHECK(!GetPromise("t1")->HasHandler())do { if ((__builtin_expect(!!(!(!GetPromise("t1")->HasHandler
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17478, "Check failed: %s."
, "!GetPromise(\"t1\")->HasHandler()"); } } while (0)
;
17479 CHECK_EQ(1, promise_reject_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (promise_reject_counter
), "1" " " "==" " " "promise_reject_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17479, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17480 CHECK_EQ(0, promise_revoke_counter)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (promise_revoke_counter
), "0" " " "==" " " "promise_revoke_counter")) { V8_Fatal("../test/cctest/test-api.cc"
, 17480, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17481 CHECK_EQ(2, promise_reject_frame_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (promise_reject_frame_count
), "2" " " "==" " " "promise_reject_frame_count")) { V8_Fatal
("../test/cctest/test-api.cc", 17481, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17482 CHECK_EQ(5, promise_reject_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (promise_reject_line_number
), "5" " " "==" " " "promise_reject_line_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17482, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17483 CHECK_EQ(10, promise_reject_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10), (
promise_reject_column_number), "10" " " "==" " " "promise_reject_column_number"
)) { V8_Fatal("../test/cctest/test-api.cc", 17483, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17484 CHECK_EQ(2, promise_reject_msg_line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (promise_reject_msg_line_number
), "2" " " "==" " " "promise_reject_msg_line_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17484, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17485 CHECK_EQ(7, promise_reject_msg_column_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (promise_reject_msg_column_number
), "7" " " "==" " " "promise_reject_msg_column_number")) { V8_Fatal
("../test/cctest/test-api.cc", 17485, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17486}
17487
17488
17489void AnalyzeStackOfEvalWithSourceURL(
17490 const v8::FunctionCallbackInfo<v8::Value>& args) {
17491 v8::HandleScope scope(args.GetIsolate());
17492 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
17493 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
17494 CHECK_EQ(5, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (stackTrace
->GetFrameCount()), "5" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17494, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17495 v8::Local<v8::String> url = v8_str("eval_url");
17496 for (int i = 0; i < 3; i++) {
17497 v8::Local<v8::String> name =
17498 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
17499 CHECK(!name.IsEmpty())do { if ((__builtin_expect(!!(!(!name.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17499, "Check failed: %s.", "!name.IsEmpty()"
); } } while (0)
;
17500 CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust())do { if ((__builtin_expect(!!(!(url->Equals(args.GetIsolate
()->GetCurrentContext(), name).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17500, "Check failed: %s.", "url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust()"
); } } while (0)
;
17501 }
17502}
17503
17504
17505TEST(SourceURLInStackTrace)static void TestSourceURLInStackTrace(); CcTest register_test_SourceURLInStackTrace
(TestSourceURLInStackTrace, "../test/cctest/test-api.cc", "SourceURLInStackTrace"
, __null, true, true); static void TestSourceURLInStackTrace(
)
{
17506 v8::Isolate* isolate = CcTest::isolate();
17507 v8::HandleScope scope(isolate);
17508 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
17509 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"),
17510 v8::FunctionTemplate::New(isolate,
17511 AnalyzeStackOfEvalWithSourceURL));
17512 LocalContext context(0, templ);
17513
17514 const char *source =
17515 "function outer() {\n"
17516 "function bar() {\n"
17517 " AnalyzeStackOfEvalWithSourceURL();\n"
17518 "}\n"
17519 "function foo() {\n"
17520 "\n"
17521 " bar();\n"
17522 "}\n"
17523 "foo();\n"
17524 "}\n"
17525 "eval('(' + outer +')()%s');";
17526
17527 i::ScopedVector<char> code(1024);
17528 i::SNPrintF(code, source, "//# sourceURL=eval_url");
17529 CHECK(CompileRun(code.start())->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRun(code.start())->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17529, "Check failed: %s.", "CompileRun(code.start())->IsUndefined()"
); } } while (0)
;
17530 i::SNPrintF(code, source, "//@ sourceURL=eval_url");
17531 CHECK(CompileRun(code.start())->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRun(code.start())->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17531, "Check failed: %s.", "CompileRun(code.start())->IsUndefined()"
); } } while (0)
;
17532}
17533
17534
17535static int scriptIdInStack[2];
17536
17537void AnalyzeScriptIdInStack(
17538 const v8::FunctionCallbackInfo<v8::Value>& args) {
17539 v8::HandleScope scope(args.GetIsolate());
17540 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
17541 args.GetIsolate(), 10, v8::StackTrace::kScriptId);
17542 CHECK_EQ(2, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (stackTrace
->GetFrameCount()), "2" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17542, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17543 for (int i = 0; i < 2; i++) {
17544 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId();
17545 }
17546}
17547
17548
17549TEST(ScriptIdInStackTrace)static void TestScriptIdInStackTrace(); CcTest register_test_ScriptIdInStackTrace
(TestScriptIdInStackTrace, "../test/cctest/test-api.cc", "ScriptIdInStackTrace"
, __null, true, true); static void TestScriptIdInStackTrace()
{
17550 v8::Isolate* isolate = CcTest::isolate();
17551 v8::HandleScope scope(isolate);
17552 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
17553 templ->Set(v8_str("AnalyzeScriptIdInStack"),
17554 v8::FunctionTemplate::New(isolate, AnalyzeScriptIdInStack));
17555 LocalContext context(0, templ);
17556
17557 v8::Local<v8::String> scriptSource = v8_str(
17558 "function foo() {\n"
17559 " AnalyzeScriptIdInStack();"
17560 "}\n"
17561 "foo();\n");
17562 v8::Local<v8::Script> script = CompileWithOrigin(scriptSource, "test");
17563 script->Run(context.local()).ToLocalChecked();
17564 for (int i = 0; i < 2; i++) {
17565 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo)do { if ((__builtin_expect(!!(!(scriptIdInStack[i] != v8::Message
::kNoScriptIdInfo)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17565, "Check failed: %s.", "scriptIdInStack[i] != v8::Message::kNoScriptIdInfo"
); } } while (0)
;
17566 CHECK_EQ(scriptIdInStack[i], script->GetUnboundScript()->GetId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (scriptIdInStack
[i]), (script->GetUnboundScript()->GetId()), "scriptIdInStack[i]"
" " "==" " " "script->GetUnboundScript()->GetId()")) {
V8_Fatal("../test/cctest/test-api.cc", 17566, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17567 }
17568}
17569
17570
17571void AnalyzeStackOfInlineScriptWithSourceURL(
17572 const v8::FunctionCallbackInfo<v8::Value>& args) {
17573 v8::HandleScope scope(args.GetIsolate());
17574 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
17575 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
17576 CHECK_EQ(4, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (stackTrace
->GetFrameCount()), "4" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17576, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17577 v8::Local<v8::String> url = v8_str("source_url");
17578 for (int i = 0; i < 3; i++) {
17579 v8::Local<v8::String> name =
17580 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
17581 CHECK(!name.IsEmpty())do { if ((__builtin_expect(!!(!(!name.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17581, "Check failed: %s.", "!name.IsEmpty()"
); } } while (0)
;
17582 CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust())do { if ((__builtin_expect(!!(!(url->Equals(args.GetIsolate
()->GetCurrentContext(), name).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17582, "Check failed: %s.", "url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust()"
); } } while (0)
;
17583 }
17584}
17585
17586
17587TEST(InlineScriptWithSourceURLInStackTrace)static void TestInlineScriptWithSourceURLInStackTrace(); CcTest
register_test_InlineScriptWithSourceURLInStackTrace(TestInlineScriptWithSourceURLInStackTrace
, "../test/cctest/test-api.cc", "InlineScriptWithSourceURLInStackTrace"
, __null, true, true); static void TestInlineScriptWithSourceURLInStackTrace
()
{
17588 v8::Isolate* isolate = CcTest::isolate();
17589 v8::HandleScope scope(isolate);
17590 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
17591 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"),
17592 v8::FunctionTemplate::New(
17593 CcTest::isolate(), AnalyzeStackOfInlineScriptWithSourceURL));
17594 LocalContext context(0, templ);
17595
17596 const char *source =
17597 "function outer() {\n"
17598 "function bar() {\n"
17599 " AnalyzeStackOfInlineScriptWithSourceURL();\n"
17600 "}\n"
17601 "function foo() {\n"
17602 "\n"
17603 " bar();\n"
17604 "}\n"
17605 "foo();\n"
17606 "}\n"
17607 "outer()\n%s";
17608
17609 i::ScopedVector<char> code(1024);
17610 i::SNPrintF(code, source, "//# sourceURL=source_url");
17611 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRunWithOrigin(code.start
(), "url", 0, 1)->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17611, "Check failed: %s.", "CompileRunWithOrigin(code.start(), \"url\", 0, 1)->IsUndefined()"
); } } while (0)
;
17612 i::SNPrintF(code, source, "//@ sourceURL=source_url");
17613 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRunWithOrigin(code.start
(), "url", 0, 1)->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17613, "Check failed: %s.", "CompileRunWithOrigin(code.start(), \"url\", 0, 1)->IsUndefined()"
); } } while (0)
;
17614}
17615
17616
17617void AnalyzeStackOfDynamicScriptWithSourceURL(
17618 const v8::FunctionCallbackInfo<v8::Value>& args) {
17619 v8::HandleScope scope(args.GetIsolate());
17620 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
17621 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
17622 CHECK_EQ(4, stackTrace->GetFrameCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (stackTrace
->GetFrameCount()), "4" " " "==" " " "stackTrace->GetFrameCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17622, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17623 v8::Local<v8::String> url = v8_str("source_url");
17624 for (int i = 0; i < 3; i++) {
17625 v8::Local<v8::String> name =
17626 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
17627 CHECK(!name.IsEmpty())do { if ((__builtin_expect(!!(!(!name.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17627, "Check failed: %s.", "!name.IsEmpty()"
); } } while (0)
;
17628 CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust())do { if ((__builtin_expect(!!(!(url->Equals(args.GetIsolate
()->GetCurrentContext(), name).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17628, "Check failed: %s.", "url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust()"
); } } while (0)
;
17629 }
17630}
17631
17632
17633TEST(DynamicWithSourceURLInStackTrace)static void TestDynamicWithSourceURLInStackTrace(); CcTest register_test_DynamicWithSourceURLInStackTrace
(TestDynamicWithSourceURLInStackTrace, "../test/cctest/test-api.cc"
, "DynamicWithSourceURLInStackTrace", __null, true, true); static
void TestDynamicWithSourceURLInStackTrace()
{
17634 v8::Isolate* isolate = CcTest::isolate();
17635 v8::HandleScope scope(isolate);
17636 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
17637 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"),
17638 v8::FunctionTemplate::New(
17639 CcTest::isolate(), AnalyzeStackOfDynamicScriptWithSourceURL));
17640 LocalContext context(0, templ);
17641
17642 const char *source =
17643 "function outer() {\n"
17644 "function bar() {\n"
17645 " AnalyzeStackOfDynamicScriptWithSourceURL();\n"
17646 "}\n"
17647 "function foo() {\n"
17648 "\n"
17649 " bar();\n"
17650 "}\n"
17651 "foo();\n"
17652 "}\n"
17653 "outer()\n%s";
17654
17655 i::ScopedVector<char> code(1024);
17656 i::SNPrintF(code, source, "//# sourceURL=source_url");
17657 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRunWithOrigin(code.start
(), "url", 0, 0)->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17657, "Check failed: %s.", "CompileRunWithOrigin(code.start(), \"url\", 0, 0)->IsUndefined()"
); } } while (0)
;
17658 i::SNPrintF(code, source, "//@ sourceURL=source_url");
17659 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined())do { if ((__builtin_expect(!!(!(CompileRunWithOrigin(code.start
(), "url", 0, 0)->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17659, "Check failed: %s.", "CompileRunWithOrigin(code.start(), \"url\", 0, 0)->IsUndefined()"
); } } while (0)
;
17660}
17661
17662
17663TEST(DynamicWithSourceURLInStackTraceString)static void TestDynamicWithSourceURLInStackTraceString(); CcTest
register_test_DynamicWithSourceURLInStackTraceString(TestDynamicWithSourceURLInStackTraceString
, "../test/cctest/test-api.cc", "DynamicWithSourceURLInStackTraceString"
, __null, true, true); static void TestDynamicWithSourceURLInStackTraceString
()
{
17664 LocalContext context;
17665 v8::HandleScope scope(context->GetIsolate());
17666
17667 const char *source =
17668 "function outer() {\n"
17669 " function foo() {\n"
17670 " FAIL.FAIL;\n"
17671 " }\n"
17672 " foo();\n"
17673 "}\n"
17674 "outer()\n%s";
17675
17676 i::ScopedVector<char> code(1024);
17677 i::SNPrintF(code, source, "//# sourceURL=source_url");
17678 v8::TryCatch try_catch(context->GetIsolate());
17679 CompileRunWithOrigin(code.start(), "", 0, 0);
17680 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17680, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
17681 v8::String::Utf8Value stack(
17682 try_catch.StackTrace(context.local()).ToLocalChecked());
17683 CHECK(strstr(*stack, "at foo (source_url:3:5)") != NULL)do { if ((__builtin_expect(!!(!(strstr(*stack, "at foo (source_url:3:5)"
) != __null)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17683
, "Check failed: %s.", "strstr(*stack, \"at foo (source_url:3:5)\") != NULL"
); } } while (0)
;
17684}
17685
17686
17687TEST(EvalWithSourceURLInMessageScriptResourceNameOrSourceURL)static void TestEvalWithSourceURLInMessageScriptResourceNameOrSourceURL
(); CcTest register_test_EvalWithSourceURLInMessageScriptResourceNameOrSourceURL
(TestEvalWithSourceURLInMessageScriptResourceNameOrSourceURL,
"../test/cctest/test-api.cc", "EvalWithSourceURLInMessageScriptResourceNameOrSourceURL"
, __null, true, true); static void TestEvalWithSourceURLInMessageScriptResourceNameOrSourceURL
()
{
17688 LocalContext context;
17689 v8::HandleScope scope(context->GetIsolate());
17690
17691 const char *source =
17692 "function outer() {\n"
17693 " var scriptContents = \"function foo() { FAIL.FAIL; }\\\n"
17694 " //# sourceURL=source_url\";\n"
17695 " eval(scriptContents);\n"
17696 " foo(); }\n"
17697 "outer();\n"
17698 "//# sourceURL=outer_url";
17699
17700 v8::TryCatch try_catch(context->GetIsolate());
17701 CompileRun(source);
17702 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17702, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
17703
17704 Local<v8::Message> message = try_catch.Message();
17705 Local<Value> sourceURL = message->GetScriptOrigin().ResourceName();
17706 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*v8::String::Utf8Value(sourceURL), "source_url")), "0" " " "=="
" " "strcmp(*v8::String::Utf8Value(sourceURL), \"source_url\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 17706, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17707}
17708
17709
17710TEST(RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL)static void TestRecursionWithSourceURLInMessageScriptResourceNameOrSourceURL
(); CcTest register_test_RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL
(TestRecursionWithSourceURLInMessageScriptResourceNameOrSourceURL
, "../test/cctest/test-api.cc", "RecursionWithSourceURLInMessageScriptResourceNameOrSourceURL"
, __null, true, true); static void TestRecursionWithSourceURLInMessageScriptResourceNameOrSourceURL
()
{
17711 LocalContext context;
17712 v8::HandleScope scope(context->GetIsolate());
17713
17714 const char *source =
17715 "function outer() {\n"
17716 " var scriptContents = \"function boo(){ boo(); }\\\n"
17717 " //# sourceURL=source_url\";\n"
17718 " eval(scriptContents);\n"
17719 " boo(); }\n"
17720 "outer();\n"
17721 "//# sourceURL=outer_url";
17722
17723 v8::TryCatch try_catch(context->GetIsolate());
17724 CompileRun(source);
17725 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17725, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
17726
17727 Local<v8::Message> message = try_catch.Message();
17728 Local<Value> sourceURL = message->GetScriptOrigin().ResourceName();
17729 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(sourceURL), "source_url"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*v8::String::Utf8Value(sourceURL), "source_url")), "0" " " "=="
" " "strcmp(*v8::String::Utf8Value(sourceURL), \"source_url\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 17729, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17730}
17731
17732
17733static void CreateGarbageInOldSpace() {
17734 i::Factory* factory = CcTest::i_isolate()->factory();
17735 v8::HandleScope scope(CcTest::isolate());
17736 i::AlwaysAllocateScope always_allocate(CcTest::i_isolate());
17737 for (int i = 0; i < 1000; i++) {
17738 factory->NewFixedArray(1000, i::TENURED);
17739 }
17740}
17741
17742
17743// Test that idle notification can be handled and eventually collects garbage.
17744TEST(TestIdleNotification)static void TestTestIdleNotification(); CcTest register_test_TestIdleNotification
(TestTestIdleNotification, "../test/cctest/test-api.cc", "TestIdleNotification"
, __null, true, true); static void TestTestIdleNotification()
{
17745 if (!i::FLAG_incremental_marking) return;
17746 const intptr_t MB = 1024 * 1024;
17747 const double IdlePauseInSeconds = 1.0;
17748 LocalContext env;
17749 v8::HandleScope scope(env->GetIsolate());
17750 intptr_t initial_size = CcTest::heap()->SizeOfObjects();
17751 CreateGarbageInOldSpace();
17752 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects();
17753 CHECK_GT(size_with_garbage, initial_size + MB)do { if (std::string* _msg = ::v8::base::CheckGTImpl( (size_with_garbage
), (initial_size + MB), "size_with_garbage" " " ">" " " "initial_size + MB"
)) { V8_Fatal("../test/cctest/test-api.cc", 17753, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17754 bool finished = false;
17755 for (int i = 0; i < 200 && !finished; i++) {
17756 if (i < 10 && CcTest::heap()->incremental_marking()->IsStopped()) {
17757 CcTest::heap()->StartIdleIncrementalMarking();
17758 }
17759 finished = env->GetIsolate()->IdleNotificationDeadline(
17760 (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
17761 static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
17762 IdlePauseInSeconds);
17763 if (CcTest::heap()->mark_compact_collector()->sweeping_in_progress()) {
17764 CcTest::heap()->mark_compact_collector()->EnsureSweepingCompleted();
17765 }
17766 }
17767 intptr_t final_size = CcTest::heap()->SizeOfObjects();
17768 CHECK(finished)do { if ((__builtin_expect(!!(!(finished)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17768, "Check failed: %s.", "finished"); } } while (0)
;
17769 CHECK_LT(final_size, initial_size + 1)do { if (std::string* _msg = ::v8::base::CheckLTImpl( (final_size
), (initial_size + 1), "final_size" " " "<" " " "initial_size + 1"
)) { V8_Fatal("../test/cctest/test-api.cc", 17769, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17770}
17771
17772
17773TEST(Regress2333)static void TestRegress2333(); CcTest register_test_Regress2333
(TestRegress2333, "../test/cctest/test-api.cc", "Regress2333"
, __null, true, true); static void TestRegress2333()
{
17774 LocalContext env;
17775 for (int i = 0; i < 3; i++) {
17776 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
17777 }
17778}
17779
17780static uint32_t* stack_limit;
17781
17782static void GetStackLimitCallback(
17783 const v8::FunctionCallbackInfo<v8::Value>& args) {
17784 stack_limit = reinterpret_cast<uint32_t*>(
17785 CcTest::i_isolate()->stack_guard()->real_climit());
17786}
17787
17788
17789// Uses the address of a local variable to determine the stack top now.
17790// Given a size, returns an address that is that far from the current
17791// top of stack.
17792static uint32_t* ComputeStackLimit(uint32_t size) {
17793 uint32_t* answer = &size - (size / sizeof(size));
17794 // If the size is very large and the stack is very near the bottom of
17795 // memory then the calculation above may wrap around and give an address
17796 // that is above the (downwards-growing) stack. In that case we return
17797 // a very low address.
17798 if (answer > &size) return reinterpret_cast<uint32_t*>(sizeof(size));
17799 return answer;
17800}
17801
17802
17803// We need at least 165kB for an x64 debug build with clang and ASAN.
17804static const int stack_breathing_room = 256 * i::KB;
17805
17806
17807TEST(SetStackLimit)static void TestSetStackLimit(); CcTest register_test_SetStackLimit
(TestSetStackLimit, "../test/cctest/test-api.cc", "SetStackLimit"
, __null, true, true); static void TestSetStackLimit()
{
17808 uint32_t* set_limit = ComputeStackLimit(stack_breathing_room);
17809
17810 // Set stack limit.
17811 CcTest::isolate()->SetStackLimit(reinterpret_cast<uintptr_t>(set_limit));
17812
17813 // Execute a script.
17814 LocalContext env;
17815 v8::HandleScope scope(env->GetIsolate());
17816 Local<v8::FunctionTemplate> fun_templ =
17817 v8::FunctionTemplate::New(env->GetIsolate(), GetStackLimitCallback);
17818 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
17819 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("get_stack_limit"), fun) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17821, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"get_stack_limit\"), fun) .FromJust()"
); } } while (0)
17820 ->Set(env.local(), v8_str("get_stack_limit"), fun)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("get_stack_limit"), fun) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17821, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"get_stack_limit\"), fun) .FromJust()"
); } } while (0)
17821 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("get_stack_limit"), fun) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17821, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"get_stack_limit\"), fun) .FromJust()"
); } } while (0)
;
17822 CompileRun("get_stack_limit();");
17823
17824 CHECK(stack_limit == set_limit)do { if ((__builtin_expect(!!(!(stack_limit == set_limit)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 17824, "Check failed: %s."
, "stack_limit == set_limit"); } } while (0)
;
17825}
17826
17827
17828TEST(SetStackLimitInThread)static void TestSetStackLimitInThread(); CcTest register_test_SetStackLimitInThread
(TestSetStackLimitInThread, "../test/cctest/test-api.cc", "SetStackLimitInThread"
, __null, true, true); static void TestSetStackLimitInThread(
)
{
17829 uint32_t* set_limit;
17830 {
17831 v8::Locker locker(CcTest::isolate());
17832 set_limit = ComputeStackLimit(stack_breathing_room);
17833
17834 // Set stack limit.
17835 CcTest::isolate()->SetStackLimit(reinterpret_cast<uintptr_t>(set_limit));
17836
17837 // Execute a script.
17838 v8::HandleScope scope(CcTest::isolate());
17839 LocalContext env;
17840 Local<v8::FunctionTemplate> fun_templ =
17841 v8::FunctionTemplate::New(CcTest::isolate(), GetStackLimitCallback);
17842 Local<Function> fun = fun_templ->GetFunction(env.local()).ToLocalChecked();
17843 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("get_stack_limit"), fun) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17845, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"get_stack_limit\"), fun) .FromJust()"
); } } while (0)
17844 ->Set(env.local(), v8_str("get_stack_limit"), fun)do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("get_stack_limit"), fun) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17845, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"get_stack_limit\"), fun) .FromJust()"
); } } while (0)
17845 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("get_stack_limit"), fun) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17845, "Check failed: %s."
, "env->Global() ->Set(env.local(), v8_str(\"get_stack_limit\"), fun) .FromJust()"
); } } while (0)
;
17846 CompileRun("get_stack_limit();");
17847
17848 CHECK(stack_limit == set_limit)do { if ((__builtin_expect(!!(!(stack_limit == set_limit)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 17848, "Check failed: %s."
, "stack_limit == set_limit"); } } while (0)
;
17849 }
17850 {
17851 v8::Locker locker(CcTest::isolate());
17852 CHECK(stack_limit == set_limit)do { if ((__builtin_expect(!!(!(stack_limit == set_limit)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 17852, "Check failed: %s."
, "stack_limit == set_limit"); } } while (0)
;
17853 }
17854}
17855
17856
17857THREADED_TEST(GetHeapStatistics)static void TestGetHeapStatistics(); RegisterThreadedTest register_GetHeapStatistics
(TestGetHeapStatistics, "GetHeapStatistics"); static void TestGetHeapStatistics
(); CcTest register_test_GetHeapStatistics(TestGetHeapStatistics
, "../test/cctest/test-api.cc", "GetHeapStatistics", __null, true
, true); static void TestGetHeapStatistics()
{
17858 LocalContext c1;
17859 v8::HandleScope scope(c1->GetIsolate());
17860 v8::HeapStatistics heap_statistics;
17861 CHECK_EQ(0u, heap_statistics.total_heap_size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
heap_statistics.total_heap_size()), "0u" " " "==" " " "heap_statistics.total_heap_size()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17861, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17862 CHECK_EQ(0u, heap_statistics.used_heap_size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0u), (
heap_statistics.used_heap_size()), "0u" " " "==" " " "heap_statistics.used_heap_size()"
)) { V8_Fatal("../test/cctest/test-api.cc", 17862, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17863 c1->GetIsolate()->GetHeapStatistics(&heap_statistics);
17864 CHECK_NE(static_cast<int>(heap_statistics.total_heap_size()), 0)do { if (std::string* _msg = ::v8::base::CheckNEImpl( (static_cast
<int>(heap_statistics.total_heap_size())), (0), "static_cast<int>(heap_statistics.total_heap_size())"
" " "!=" " " "0")) { V8_Fatal("../test/cctest/test-api.cc", 17864
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
17865 CHECK_NE(static_cast<int>(heap_statistics.used_heap_size()), 0)do { if (std::string* _msg = ::v8::base::CheckNEImpl( (static_cast
<int>(heap_statistics.used_heap_size())), (0), "static_cast<int>(heap_statistics.used_heap_size())"
" " "!=" " " "0")) { V8_Fatal("../test/cctest/test-api.cc", 17865
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
17866}
17867
17868
17869class VisitorImpl : public v8::ExternalResourceVisitor {
17870 public:
17871 explicit VisitorImpl(TestResource** resource) {
17872 for (int i = 0; i < 4; i++) {
17873 resource_[i] = resource[i];
17874 found_resource_[i] = false;
17875 }
17876 }
17877 virtual ~VisitorImpl() {}
17878 virtual void VisitExternalString(v8::Local<v8::String> string) {
17879 if (!string->IsExternal()) {
17880 CHECK(string->IsExternalOneByte())do { if ((__builtin_expect(!!(!(string->IsExternalOneByte(
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17880, "Check failed: %s."
, "string->IsExternalOneByte()"); } } while (0)
;
17881 return;
17882 }
17883 v8::String::ExternalStringResource* resource =
17884 string->GetExternalStringResource();
17885 CHECK(resource)do { if ((__builtin_expect(!!(!(resource)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17885, "Check failed: %s.", "resource"); } } while (0)
;
17886 for (int i = 0; i < 4; i++) {
17887 if (resource_[i] == resource) {
17888 CHECK(!found_resource_[i])do { if ((__builtin_expect(!!(!(!found_resource_[i])), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 17888, "Check failed: %s."
, "!found_resource_[i]"); } } while (0)
;
17889 found_resource_[i] = true;
17890 }
17891 }
17892 }
17893 void CheckVisitedResources() {
17894 for (int i = 0; i < 4; i++) {
17895 CHECK(found_resource_[i])do { if ((__builtin_expect(!!(!(found_resource_[i])), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17895, "Check failed: %s.", "found_resource_[i]"
); } } while (0)
;
17896 }
17897 }
17898
17899 private:
17900 v8::String::ExternalStringResource* resource_[4];
17901 bool found_resource_[4];
17902};
17903
17904
17905TEST(ExternalizeOldSpaceTwoByteCons)static void TestExternalizeOldSpaceTwoByteCons(); CcTest register_test_ExternalizeOldSpaceTwoByteCons
(TestExternalizeOldSpaceTwoByteCons, "../test/cctest/test-api.cc"
, "ExternalizeOldSpaceTwoByteCons", __null, true, true); static
void TestExternalizeOldSpaceTwoByteCons()
{
17906 v8::Isolate* isolate = CcTest::isolate();
17907 LocalContext env;
17908 v8::HandleScope scope(isolate);
17909 v8::Local<v8::String> cons =
17910 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")
17911 ->ToString(env.local())
17912 .ToLocalChecked();
17913 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*cons)->
IsConsString())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17913, "Check failed: %s.", "v8::Utils::OpenHandle(*cons)->IsConsString()"
); } } while (0)
;
17914 CcTest::heap()->CollectAllAvailableGarbage();
17915 CHECK(CcTest::heap()->old_space()->Contains(*v8::Utils::OpenHandle(*cons)))do { if ((__builtin_expect(!!(!(CcTest::heap()->old_space(
)->Contains(*v8::Utils::OpenHandle(*cons)))), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17915, "Check failed: %s.", "CcTest::heap()->old_space()->Contains(*v8::Utils::OpenHandle(*cons))"
); } } while (0)
;
17916
17917 TestResource* resource = new TestResource(
17918 AsciiToTwoByteString("Romeo Montague Juliet Capulet"));
17919 cons->MakeExternal(resource);
17920
17921 CHECK(cons->IsExternal())do { if ((__builtin_expect(!!(!(cons->IsExternal())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 17921, "Check failed: %s."
, "cons->IsExternal()"); } } while (0)
;
17922 CHECK_EQ(resource, cons->GetExternalStringResource())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (resource
), (cons->GetExternalStringResource()), "resource" " " "=="
" " "cons->GetExternalStringResource()")) { V8_Fatal("../test/cctest/test-api.cc"
, 17922, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17923 String::Encoding encoding;
17924 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (resource
), (cons->GetExternalStringResourceBase(&encoding)), "resource"
" " "==" " " "cons->GetExternalStringResourceBase(&encoding)"
)) { V8_Fatal("../test/cctest/test-api.cc", 17924, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17925 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (String
::TWO_BYTE_ENCODING), (encoding), "String::TWO_BYTE_ENCODING"
" " "==" " " "encoding")) { V8_Fatal("../test/cctest/test-api.cc"
, 17925, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17926}
17927
17928
17929TEST(ExternalizeOldSpaceOneByteCons)static void TestExternalizeOldSpaceOneByteCons(); CcTest register_test_ExternalizeOldSpaceOneByteCons
(TestExternalizeOldSpaceOneByteCons, "../test/cctest/test-api.cc"
, "ExternalizeOldSpaceOneByteCons", __null, true, true); static
void TestExternalizeOldSpaceOneByteCons()
{
17930 v8::Isolate* isolate = CcTest::isolate();
17931 LocalContext env;
17932 v8::HandleScope scope(isolate);
17933 v8::Local<v8::String> cons =
17934 CompileRun("'Romeo Montague ' + 'Juliet Capulet'")
17935 ->ToString(env.local())
17936 .ToLocalChecked();
17937 CHECK(v8::Utils::OpenHandle(*cons)->IsConsString())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*cons)->
IsConsString())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 17937, "Check failed: %s.", "v8::Utils::OpenHandle(*cons)->IsConsString()"
); } } while (0)
;
17938 CcTest::heap()->CollectAllAvailableGarbage();
17939 CHECK(CcTest::heap()->old_space()->Contains(*v8::Utils::OpenHandle(*cons)))do { if ((__builtin_expect(!!(!(CcTest::heap()->old_space(
)->Contains(*v8::Utils::OpenHandle(*cons)))), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17939, "Check failed: %s.", "CcTest::heap()->old_space()->Contains(*v8::Utils::OpenHandle(*cons))"
); } } while (0)
;
17940
17941 TestOneByteResource* resource =
17942 new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet"));
17943 cons->MakeExternal(resource);
17944
17945 CHECK(cons->IsExternalOneByte())do { if ((__builtin_expect(!!(!(cons->IsExternalOneByte())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17945, "Check failed: %s."
, "cons->IsExternalOneByte()"); } } while (0)
;
17946 CHECK_EQ(resource, cons->GetExternalOneByteStringResource())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (resource
), (cons->GetExternalOneByteStringResource()), "resource" " "
"==" " " "cons->GetExternalOneByteStringResource()")) { V8_Fatal
("../test/cctest/test-api.cc", 17946, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
17947 String::Encoding encoding;
17948 CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (resource
), (cons->GetExternalStringResourceBase(&encoding)), "resource"
" " "==" " " "cons->GetExternalStringResourceBase(&encoding)"
)) { V8_Fatal("../test/cctest/test-api.cc", 17948, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
17949 CHECK_EQ(String::ONE_BYTE_ENCODING, encoding)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (String
::ONE_BYTE_ENCODING), (encoding), "String::ONE_BYTE_ENCODING"
" " "==" " " "encoding")) { V8_Fatal("../test/cctest/test-api.cc"
, 17949, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
17950}
17951
17952
17953TEST(VisitExternalStrings)static void TestVisitExternalStrings(); CcTest register_test_VisitExternalStrings
(TestVisitExternalStrings, "../test/cctest/test-api.cc", "VisitExternalStrings"
, __null, true, true); static void TestVisitExternalStrings()
{
17954 v8::Isolate* isolate = CcTest::isolate();
17955 LocalContext env;
17956 v8::HandleScope scope(isolate);
17957 const char* string = "Some string";
17958 uint16_t* two_byte_string = AsciiToTwoByteString(string);
17959 TestResource* resource[4];
17960 resource[0] = new TestResource(two_byte_string);
17961 v8::Local<v8::String> string0 =
17962 v8::String::NewExternalTwoByte(env->GetIsolate(), resource[0])
17963 .ToLocalChecked();
17964 resource[1] = new TestResource(two_byte_string, NULL__null, false);
17965 v8::Local<v8::String> string1 =
17966 v8::String::NewExternalTwoByte(env->GetIsolate(), resource[1])
17967 .ToLocalChecked();
17968
17969 // Externalized symbol.
17970 resource[2] = new TestResource(two_byte_string, NULL__null, false);
17971 v8::Local<v8::String> string2 =
17972 v8::String::NewFromUtf8(env->GetIsolate(), string,
17973 v8::NewStringType::kInternalized)
17974 .ToLocalChecked();
17975 CHECK(string2->MakeExternal(resource[2]))do { if ((__builtin_expect(!!(!(string2->MakeExternal(resource
[2]))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17975, "Check failed: %s."
, "string2->MakeExternal(resource[2])"); } } while (0)
;
17976
17977 // Symbolized External.
17978 resource[3] = new TestResource(AsciiToTwoByteString("Some other string"));
17979 v8::Local<v8::String> string3 =
17980 v8::String::NewExternalTwoByte(env->GetIsolate(), resource[3])
17981 .ToLocalChecked();
17982 CcTest::heap()->CollectAllAvailableGarbage(); // Tenure string.
17983 // Turn into a symbol.
17984 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3);
17985 CHECK(!CcTest::i_isolate()->factory()->InternalizeString(do { if ((__builtin_expect(!!(!(!CcTest::i_isolate()->factory
()->InternalizeString( string3_i).is_null())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17986, "Check failed: %s.", "!CcTest::i_isolate()->factory()->InternalizeString( string3_i).is_null()"
); } } while (0)
17986 string3_i).is_null())do { if ((__builtin_expect(!!(!(!CcTest::i_isolate()->factory
()->InternalizeString( string3_i).is_null())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 17986, "Check failed: %s.", "!CcTest::i_isolate()->factory()->InternalizeString( string3_i).is_null()"
); } } while (0)
;
17987 CHECK(string3_i->IsInternalizedString())do { if ((__builtin_expect(!!(!(string3_i->IsInternalizedString
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 17987, "Check failed: %s."
, "string3_i->IsInternalizedString()"); } } while (0)
;
17988
17989 // We need to add usages for string* to avoid warnings in GCC 4.7
17990 CHECK(string0->IsExternal())do { if ((__builtin_expect(!!(!(string0->IsExternal())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 17990, "Check failed: %s."
, "string0->IsExternal()"); } } while (0)
;
17991 CHECK(string1->IsExternal())do { if ((__builtin_expect(!!(!(string1->IsExternal())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 17991, "Check failed: %s."
, "string1->IsExternal()"); } } while (0)
;
17992 CHECK(string2->IsExternal())do { if ((__builtin_expect(!!(!(string2->IsExternal())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 17992, "Check failed: %s."
, "string2->IsExternal()"); } } while (0)
;
17993 CHECK(string3->IsExternal())do { if ((__builtin_expect(!!(!(string3->IsExternal())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 17993, "Check failed: %s."
, "string3->IsExternal()"); } } while (0)
;
17994
17995 VisitorImpl visitor(resource);
17996 isolate->VisitExternalResources(&visitor);
17997 visitor.CheckVisitedResources();
17998}
17999
18000
18001TEST(ExternalStringCollectedAtTearDown)static void TestExternalStringCollectedAtTearDown(); CcTest register_test_ExternalStringCollectedAtTearDown
(TestExternalStringCollectedAtTearDown, "../test/cctest/test-api.cc"
, "ExternalStringCollectedAtTearDown", __null, true, true); static
void TestExternalStringCollectedAtTearDown()
{
18002 int destroyed = 0;
18003 v8::Isolate::CreateParams create_params;
18004 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
18005 v8::Isolate* isolate = v8::Isolate::New(create_params);
18006 { v8::Isolate::Scope isolate_scope(isolate);
18007 v8::HandleScope handle_scope(isolate);
18008 const char* s = "One string to test them all, one string to find them.";
18009 TestOneByteResource* inscription =
18010 new TestOneByteResource(i::StrDup(s), &destroyed);
18011 v8::Local<v8::String> ring =
18012 v8::String::NewExternalOneByte(isolate, inscription).ToLocalChecked();
18013 // Ring is still alive. Orcs are roaming freely across our lands.
18014 CHECK_EQ(0, destroyed)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (destroyed
), "0" " " "==" " " "destroyed")) { V8_Fatal("../test/cctest/test-api.cc"
, 18014, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18015 USE(ring);
18016 }
18017
18018 isolate->Dispose();
18019 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice.
18020 CHECK_EQ(1, destroyed)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (destroyed
), "1" " " "==" " " "destroyed")) { V8_Fatal("../test/cctest/test-api.cc"
, 18020, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18021}
18022
18023
18024TEST(ExternalInternalizedStringCollectedAtTearDown)static void TestExternalInternalizedStringCollectedAtTearDown
(); CcTest register_test_ExternalInternalizedStringCollectedAtTearDown
(TestExternalInternalizedStringCollectedAtTearDown, "../test/cctest/test-api.cc"
, "ExternalInternalizedStringCollectedAtTearDown", __null, true
, true); static void TestExternalInternalizedStringCollectedAtTearDown
()
{
18025 int destroyed = 0;
18026 v8::Isolate::CreateParams create_params;
18027 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
18028 v8::Isolate* isolate = v8::Isolate::New(create_params);
18029 { v8::Isolate::Scope isolate_scope(isolate);
18030 LocalContext env(isolate);
18031 v8::HandleScope handle_scope(isolate);
18032 CompileRun("var ring = 'One string to test them all';");
18033 const char* s = "One string to test them all";
18034 TestOneByteResource* inscription =
18035 new TestOneByteResource(i::StrDup(s), &destroyed);
18036 v8::Local<v8::String> ring =
18037 CompileRun("ring")->ToString(env.local()).ToLocalChecked();
18038 CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*ring)->
IsInternalizedString())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18038, "Check failed: %s.", "v8::Utils::OpenHandle(*ring)->IsInternalizedString()"
); } } while (0)
;
18039 ring->MakeExternal(inscription);
18040 // Ring is still alive. Orcs are roaming freely across our lands.
18041 CHECK_EQ(0, destroyed)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (destroyed
), "0" " " "==" " " "destroyed")) { V8_Fatal("../test/cctest/test-api.cc"
, 18041, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18042 USE(ring);
18043 }
18044
18045 isolate->Dispose();
18046 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice.
18047 CHECK_EQ(1, destroyed)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (destroyed
), "1" " " "==" " " "destroyed")) { V8_Fatal("../test/cctest/test-api.cc"
, 18047, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18048}
18049
18050
18051TEST(ExternalInternalizedStringCollectedAtGC)static void TestExternalInternalizedStringCollectedAtGC(); CcTest
register_test_ExternalInternalizedStringCollectedAtGC(TestExternalInternalizedStringCollectedAtGC
, "../test/cctest/test-api.cc", "ExternalInternalizedStringCollectedAtGC"
, __null, true, true); static void TestExternalInternalizedStringCollectedAtGC
()
{
18052 int destroyed = 0;
18053 { LocalContext env;
18054 v8::HandleScope handle_scope(env->GetIsolate());
18055 CompileRun("var ring = 'One string to test them all';");
18056 const char* s = "One string to test them all";
18057 TestOneByteResource* inscription =
18058 new TestOneByteResource(i::StrDup(s), &destroyed);
18059 v8::Local<v8::String> ring = CompileRun("ring").As<v8::String>();
18060 CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*ring)->
IsInternalizedString())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18060, "Check failed: %s.", "v8::Utils::OpenHandle(*ring)->IsInternalizedString()"
); } } while (0)
;
18061 ring->MakeExternal(inscription);
18062 // Ring is still alive. Orcs are roaming freely across our lands.
18063 CHECK_EQ(0, destroyed)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (destroyed
), "0" " " "==" " " "destroyed")) { V8_Fatal("../test/cctest/test-api.cc"
, 18063, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18064 USE(ring);
18065 }
18066
18067 // Garbage collector deals swift blows to evil.
18068 CcTest::i_isolate()->compilation_cache()->Clear();
18069 CcTest::heap()->CollectAllAvailableGarbage();
18070
18071 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice.
18072 CHECK_EQ(1, destroyed)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (destroyed
), "1" " " "==" " " "destroyed")) { V8_Fatal("../test/cctest/test-api.cc"
, 18072, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18073}
18074
18075
18076static double DoubleFromBits(uint64_t value) {
18077 double target;
18078 i::MemCopy(&target, &value, sizeof(target));
18079 return target;
18080}
18081
18082
18083static uint64_t DoubleToBits(double value) {
18084 uint64_t target;
18085 i::MemCopy(&target, &value, sizeof(target));
18086 return target;
18087}
18088
18089
18090static double DoubleToDateTime(double input) {
18091 double date_limit = 864e13;
18092 if (std::isnan(input) || input < -date_limit || input > date_limit) {
18093 return std::numeric_limits<double>::quiet_NaN();
18094 }
18095 return (input < 0) ? -(std::floor(-input)) : std::floor(input);
18096}
18097
18098
18099// We don't have a consistent way to write 64-bit constants syntactically, so we
18100// split them into two 32-bit constants and combine them programmatically.
18101static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) {
18102 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits);
18103}
18104
18105
18106THREADED_TEST(QuietSignalingNaNs)static void TestQuietSignalingNaNs(); RegisterThreadedTest register_QuietSignalingNaNs
(TestQuietSignalingNaNs, "QuietSignalingNaNs"); static void TestQuietSignalingNaNs
(); CcTest register_test_QuietSignalingNaNs(TestQuietSignalingNaNs
, "../test/cctest/test-api.cc", "QuietSignalingNaNs", __null,
true, true); static void TestQuietSignalingNaNs()
{
18107 LocalContext context;
18108 v8::Isolate* isolate = context->GetIsolate();
18109 v8::HandleScope scope(isolate);
18110 v8::TryCatch try_catch(isolate);
18111
18112 // Special double values.
18113 double snan = DoubleFromBits(0x7ff00000, 0x00000001);
18114 double qnan = DoubleFromBits(0x7ff80000, 0x00000000);
18115 double infinity = DoubleFromBits(0x7ff00000, 0x00000000);
18116 double max_normal = DoubleFromBits(0x7fefffff, 0xffffffffu);
18117 double min_normal = DoubleFromBits(0x00100000, 0x00000000);
18118 double max_denormal = DoubleFromBits(0x000fffff, 0xffffffffu);
18119 double min_denormal = DoubleFromBits(0x00000000, 0x00000001);
18120
18121 // Date values are capped at +/-100000000 days (times 864e5 ms per day)
18122 // on either side of the epoch.
18123 double date_limit = 864e13;
18124
18125 double test_values[] = {
18126 snan,
18127 qnan,
18128 infinity,
18129 max_normal,
18130 date_limit + 1,
18131 date_limit,
18132 min_normal,
18133 max_denormal,
18134 min_denormal,
18135 0,
18136 -0,
18137 -min_denormal,
18138 -max_denormal,
18139 -min_normal,
18140 -date_limit,
18141 -date_limit - 1,
18142 -max_normal,
18143 -infinity,
18144 -qnan,
18145 -snan
18146 };
18147 int num_test_values = 20;
18148
18149 for (int i = 0; i < num_test_values; i++) {
18150 double test_value = test_values[i];
18151
18152 // Check that Number::New preserves non-NaNs and quiets SNaNs.
18153 v8::Local<v8::Value> number = v8::Number::New(isolate, test_value);
18154 double stored_number = number->NumberValue(context.local()).FromJust();
18155 if (!std::isnan(test_value)) {
18156 CHECK_EQ(test_value, stored_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (test_value
), (stored_number), "test_value" " " "==" " " "stored_number"
)) { V8_Fatal("../test/cctest/test-api.cc", 18156, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18157 } else {
18158 uint64_t stored_bits = DoubleToBits(stored_number);
18159 // Check if quiet nan (bits 51..62 all set).
18160#if (defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64)) && \
18161 !defined(_MIPS_ARCH_MIPS64R6) && !defined(_MIPS_ARCH_MIPS32R6) && \
18162 !defined(USE_SIMULATOR)
18163 // Most significant fraction bit for quiet nan is set to 0
18164 // on MIPS architecture. Allowed by IEEE-754.
18165 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xffe)
, (static_cast<int>((stored_bits >> 51) & 0xfff
)), "0xffe" " " "==" " " "static_cast<int>((stored_bits >> 51) & 0xfff)"
)) { V8_Fatal("../test/cctest/test-api.cc", 18165, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18166#else
18167 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xfff)
, (static_cast<int>((stored_bits >> 51) & 0xfff
)), "0xfff" " " "==" " " "static_cast<int>((stored_bits >> 51) & 0xfff)"
)) { V8_Fatal("../test/cctest/test-api.cc", 18167, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18168#endif
18169 }
18170
18171 // Check that Date::New preserves non-NaNs in the date range and
18172 // quiets SNaNs.
18173 v8::Local<v8::Value> date =
18174 v8::Date::New(context.local(), test_value).ToLocalChecked();
18175 double expected_stored_date = DoubleToDateTime(test_value);
18176 double stored_date = date->NumberValue(context.local()).FromJust();
18177 if (!std::isnan(expected_stored_date)) {
18178 CHECK_EQ(expected_stored_date, stored_date)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected_stored_date
), (stored_date), "expected_stored_date" " " "==" " " "stored_date"
)) { V8_Fatal("../test/cctest/test-api.cc", 18178, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18179 } else {
18180 uint64_t stored_bits = DoubleToBits(stored_date);
18181 // Check if quiet nan (bits 51..62 all set).
18182#if (defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64)) && \
18183 !defined(_MIPS_ARCH_MIPS64R6) && !defined(_MIPS_ARCH_MIPS32R6) && \
18184 !defined(USE_SIMULATOR)
18185 // Most significant fraction bit for quiet nan is set to 0
18186 // on MIPS architecture. Allowed by IEEE-754.
18187 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xffe)
, (static_cast<int>((stored_bits >> 51) & 0xfff
)), "0xffe" " " "==" " " "static_cast<int>((stored_bits >> 51) & 0xfff)"
)) { V8_Fatal("../test/cctest/test-api.cc", 18187, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18188#else
18189 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0xfff)
, (static_cast<int>((stored_bits >> 51) & 0xfff
)), "0xfff" " " "==" " " "static_cast<int>((stored_bits >> 51) & 0xfff)"
)) { V8_Fatal("../test/cctest/test-api.cc", 18189, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18190#endif
18191 }
18192 }
18193}
18194
18195
18196static void SpaghettiIncident(
18197 const v8::FunctionCallbackInfo<v8::Value>& args) {
18198 v8::HandleScope scope(args.GetIsolate());
18199 v8::TryCatch tc(args.GetIsolate());
18200 v8::MaybeLocal<v8::String> str(
18201 args[0]->ToString(args.GetIsolate()->GetCurrentContext()));
18202 USE(str);
18203 if (tc.HasCaught())
18204 tc.ReThrow();
18205}
18206
18207
18208// Test that an exception can be propagated down through a spaghetti
18209// stack using ReThrow.
18210THREADED_TEST(SpaghettiStackReThrow)static void TestSpaghettiStackReThrow(); RegisterThreadedTest
register_SpaghettiStackReThrow(TestSpaghettiStackReThrow, "SpaghettiStackReThrow"
); static void TestSpaghettiStackReThrow(); CcTest register_test_SpaghettiStackReThrow
(TestSpaghettiStackReThrow, "../test/cctest/test-api.cc", "SpaghettiStackReThrow"
, __null, true, true); static void TestSpaghettiStackReThrow(
)
{
18211 v8::Isolate* isolate = CcTest::isolate();
18212 v8::HandleScope scope(isolate);
18213 LocalContext context;
18214 context->Global()
18215 ->Set(context.local(), v8_str("s"),
18216 v8::FunctionTemplate::New(isolate, SpaghettiIncident)
18217 ->GetFunction(context.local())
18218 .ToLocalChecked())
18219 .FromJust();
18220 v8::TryCatch try_catch(isolate);
18221 CompileRun(
18222 "var i = 0;"
18223 "var o = {"
18224 " toString: function () {"
18225 " if (i == 10) {"
18226 " throw 'Hey!';"
18227 " } else {"
18228 " i++;"
18229 " return s(o);"
18230 " }"
18231 " }"
18232 "};"
18233 "s(o);");
18234 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 18234, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
18235 v8::String::Utf8Value value(try_catch.Exception());
18236 CHECK_EQ(0, strcmp(*value, "Hey!"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*value, "Hey!")), "0" " " "==" " " "strcmp(*value, \"Hey!\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 18236, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18237}
18238
18239
18240TEST(Regress528)static void TestRegress528(); CcTest register_test_Regress528
(TestRegress528, "../test/cctest/test-api.cc", "Regress528", __null
, true, true); static void TestRegress528()
{
18241 v8::V8::Initialize();
18242 v8::Isolate* isolate = CcTest::isolate();
18243 i::FLAG_retain_maps_for_n_gc = 0;
18244 v8::HandleScope scope(isolate);
18245 v8::Local<Context> other_context;
18246 int gc_count;
18247
18248 // Create a context used to keep the code from aging in the compilation
18249 // cache.
18250 other_context = Context::New(isolate);
18251
18252 // Context-dependent context data creates reference from the compilation
18253 // cache to the global object.
18254 const char* source_simple = "1";
18255 {
18256 v8::HandleScope scope(isolate);
18257 v8::Local<Context> context = Context::New(isolate);
18258
18259 context->Enter();
18260 Local<v8::String> obj = v8_str("");
18261 context->SetEmbedderData(0, obj);
18262 CompileRun(source_simple);
18263 context->Exit();
18264 }
18265 isolate->ContextDisposedNotification();
18266 for (gc_count = 1; gc_count < 10; gc_count++) {
18267 other_context->Enter();
18268 CompileRun(source_simple);
18269 other_context->Exit();
18270 CcTest::heap()->CollectAllGarbage();
18271 if (GetGlobalObjectsCount() == 1) break;
18272 }
18273 CHECK_GE(2, gc_count)do { if (std::string* _msg = ::v8::base::CheckGEImpl( (2), (gc_count
), "2" " " ">=" " " "gc_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18273, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18274 CHECK_EQ(1, GetGlobalObjectsCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (GetGlobalObjectsCount
()), "1" " " "==" " " "GetGlobalObjectsCount()")) { V8_Fatal(
"../test/cctest/test-api.cc", 18274, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18275
18276 // Eval in a function creates reference from the compilation cache to the
18277 // global object.
18278 const char* source_eval = "function f(){eval('1')}; f()";
18279 {
18280 v8::HandleScope scope(isolate);
18281 v8::Local<Context> context = Context::New(isolate);
18282
18283 context->Enter();
18284 CompileRun(source_eval);
18285 context->Exit();
18286 }
18287 isolate->ContextDisposedNotification();
18288 for (gc_count = 1; gc_count < 10; gc_count++) {
18289 other_context->Enter();
18290 CompileRun(source_eval);
18291 other_context->Exit();
18292 CcTest::heap()->CollectAllGarbage();
18293 if (GetGlobalObjectsCount() == 1) break;
18294 }
18295 CHECK_GE(2, gc_count)do { if (std::string* _msg = ::v8::base::CheckGEImpl( (2), (gc_count
), "2" " " ">=" " " "gc_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18295, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18296 CHECK_EQ(1, GetGlobalObjectsCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (GetGlobalObjectsCount
()), "1" " " "==" " " "GetGlobalObjectsCount()")) { V8_Fatal(
"../test/cctest/test-api.cc", 18296, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18297
18298 // Looking up the line number for an exception creates reference from the
18299 // compilation cache to the global object.
18300 const char* source_exception = "function f(){throw 1;} f()";
18301 {
18302 v8::HandleScope scope(isolate);
18303 v8::Local<Context> context = Context::New(isolate);
18304
18305 context->Enter();
18306 v8::TryCatch try_catch(isolate);
18307 CompileRun(source_exception);
18308 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 18308, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
18309 v8::Local<v8::Message> message = try_catch.Message();
18310 CHECK(!message.IsEmpty())do { if ((__builtin_expect(!!(!(!message.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 18310, "Check failed: %s.", "!message.IsEmpty()"
); } } while (0)
;
18311 CHECK_EQ(1, message->GetLineNumber(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (message
->GetLineNumber(context).FromJust()), "1" " " "==" " " "message->GetLineNumber(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18311, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18312 context->Exit();
18313 }
18314 isolate->ContextDisposedNotification();
18315 for (gc_count = 1; gc_count < 10; gc_count++) {
18316 other_context->Enter();
18317 CompileRun(source_exception);
18318 other_context->Exit();
18319 CcTest::heap()->CollectAllGarbage();
18320 if (GetGlobalObjectsCount() == 1) break;
18321 }
18322 CHECK_GE(2, gc_count)do { if (std::string* _msg = ::v8::base::CheckGEImpl( (2), (gc_count
), "2" " " ">=" " " "gc_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18322, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18323 CHECK_EQ(1, GetGlobalObjectsCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (GetGlobalObjectsCount
()), "1" " " "==" " " "GetGlobalObjectsCount()")) { V8_Fatal(
"../test/cctest/test-api.cc", 18323, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18324
18325 isolate->ContextDisposedNotification();
18326}
18327
18328
18329THREADED_TEST(ScriptOrigin)static void TestScriptOrigin(); RegisterThreadedTest register_ScriptOrigin
(TestScriptOrigin, "ScriptOrigin"); static void TestScriptOrigin
(); CcTest register_test_ScriptOrigin(TestScriptOrigin, "../test/cctest/test-api.cc"
, "ScriptOrigin", __null, true, true); static void TestScriptOrigin
()
{
18330 LocalContext env;
18331 v8::HandleScope scope(env->GetIsolate());
18332 v8::ScriptOrigin origin = v8::ScriptOrigin(
18333 v8_str("test"), v8::Integer::New(env->GetIsolate(), 1),
18334 v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()),
18335 v8::Local<v8::Integer>(), v8::True(env->GetIsolate()),
18336 v8_str("http://sourceMapUrl"), v8::True(env->GetIsolate()));
18337 v8::Local<v8::String> script = v8_str("function f() {}\n\nfunction g() {}");
18338 v8::Script::Compile(env.local(), script, &origin)
18339 .ToLocalChecked()
18340 ->Run(env.local())
18341 .ToLocalChecked();
18342 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
18343 env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked());
18344 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
18345 env->Global()->Get(env.local(), v8_str("g")).ToLocalChecked());
18346
18347 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin();
18348 CHECK_EQ(0, strcmp("test",do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("test", *v8::String::Utf8Value(script_origin_f.ResourceName(
)))), "0" " " "==" " " "strcmp(\"test\", *v8::String::Utf8Value(script_origin_f.ResourceName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18349, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18349 *v8::String::Utf8Value(script_origin_f.ResourceName())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("test", *v8::String::Utf8Value(script_origin_f.ResourceName(
)))), "0" " " "==" " " "strcmp(\"test\", *v8::String::Utf8Value(script_origin_f.ResourceName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18349, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18350 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (script_origin_f
.ResourceLineOffset()->Int32Value(env.local()).FromJust())
, "1" " " "==" " " "script_origin_f.ResourceLineOffset()->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18352, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18351 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (script_origin_f
.ResourceLineOffset()->Int32Value(env.local()).FromJust())
, "1" " " "==" " " "script_origin_f.ResourceLineOffset()->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18352, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18352 script_origin_f.ResourceLineOffset()->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (script_origin_f
.ResourceLineOffset()->Int32Value(env.local()).FromJust())
, "1" " " "==" " " "script_origin_f.ResourceLineOffset()->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18352, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18353 CHECK(script_origin_f.Options().IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(script_origin_f.Options().IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18353, "Check failed: %s."
, "script_origin_f.Options().IsSharedCrossOrigin()"); } } while
(0)
;
18354 CHECK(script_origin_f.Options().IsEmbedderDebugScript())do { if ((__builtin_expect(!!(!(script_origin_f.Options().IsEmbedderDebugScript
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18354, "Check failed: %s."
, "script_origin_f.Options().IsEmbedderDebugScript()"); } } while
(0)
;
18355 CHECK(script_origin_f.Options().IsOpaque())do { if ((__builtin_expect(!!(!(script_origin_f.Options().IsOpaque
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18355, "Check failed: %s."
, "script_origin_f.Options().IsOpaque()"); } } while (0)
;
18356 printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined());
18357
18358 CHECK_EQ(0, strcmp("http://sourceMapUrl",do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("http://sourceMapUrl", *v8::String::Utf8Value(script_origin_f
.SourceMapUrl()))), "0" " " "==" " " "strcmp(\"http://sourceMapUrl\", *v8::String::Utf8Value(script_origin_f.SourceMapUrl()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18359, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18359 *v8::String::Utf8Value(script_origin_f.SourceMapUrl())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("http://sourceMapUrl", *v8::String::Utf8Value(script_origin_f
.SourceMapUrl()))), "0" " " "==" " " "strcmp(\"http://sourceMapUrl\", *v8::String::Utf8Value(script_origin_f.SourceMapUrl()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18359, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18360
18361 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin();
18362 CHECK_EQ(0, strcmp("test",do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("test", *v8::String::Utf8Value(script_origin_g.ResourceName(
)))), "0" " " "==" " " "strcmp(\"test\", *v8::String::Utf8Value(script_origin_g.ResourceName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18363, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18363 *v8::String::Utf8Value(script_origin_g.ResourceName())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("test", *v8::String::Utf8Value(script_origin_g.ResourceName(
)))), "0" " " "==" " " "strcmp(\"test\", *v8::String::Utf8Value(script_origin_g.ResourceName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18363, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18364 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (script_origin_g
.ResourceLineOffset()->Int32Value(env.local()).FromJust())
, "1" " " "==" " " "script_origin_g.ResourceLineOffset()->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18366, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18365 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (script_origin_g
.ResourceLineOffset()->Int32Value(env.local()).FromJust())
, "1" " " "==" " " "script_origin_g.ResourceLineOffset()->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18366, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18366 script_origin_g.ResourceLineOffset()->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (script_origin_g
.ResourceLineOffset()->Int32Value(env.local()).FromJust())
, "1" " " "==" " " "script_origin_g.ResourceLineOffset()->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18366, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18367 CHECK(script_origin_g.Options().IsSharedCrossOrigin())do { if ((__builtin_expect(!!(!(script_origin_g.Options().IsSharedCrossOrigin
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18367, "Check failed: %s."
, "script_origin_g.Options().IsSharedCrossOrigin()"); } } while
(0)
;
18368 CHECK(script_origin_g.Options().IsEmbedderDebugScript())do { if ((__builtin_expect(!!(!(script_origin_g.Options().IsEmbedderDebugScript
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18368, "Check failed: %s."
, "script_origin_g.Options().IsEmbedderDebugScript()"); } } while
(0)
;
18369 CHECK(script_origin_g.Options().IsOpaque())do { if ((__builtin_expect(!!(!(script_origin_g.Options().IsOpaque
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18369, "Check failed: %s."
, "script_origin_g.Options().IsOpaque()"); } } while (0)
;
18370 CHECK_EQ(0, strcmp("http://sourceMapUrl",do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("http://sourceMapUrl", *v8::String::Utf8Value(script_origin_g
.SourceMapUrl()))), "0" " " "==" " " "strcmp(\"http://sourceMapUrl\", *v8::String::Utf8Value(script_origin_g.SourceMapUrl()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18371, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18371 *v8::String::Utf8Value(script_origin_g.SourceMapUrl())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("http://sourceMapUrl", *v8::String::Utf8Value(script_origin_g
.SourceMapUrl()))), "0" " " "==" " " "strcmp(\"http://sourceMapUrl\", *v8::String::Utf8Value(script_origin_g.SourceMapUrl()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18371, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18372}
18373
18374
18375THREADED_TEST(FunctionGetInferredName)static void TestFunctionGetInferredName(); RegisterThreadedTest
register_FunctionGetInferredName(TestFunctionGetInferredName
, "FunctionGetInferredName"); static void TestFunctionGetInferredName
(); CcTest register_test_FunctionGetInferredName(TestFunctionGetInferredName
, "../test/cctest/test-api.cc", "FunctionGetInferredName", __null
, true, true); static void TestFunctionGetInferredName()
{
18376 LocalContext env;
18377 v8::HandleScope scope(env->GetIsolate());
18378 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
18379 v8::Local<v8::String> script =
18380 v8_str("var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;");
18381 v8::Script::Compile(env.local(), script, &origin)
18382 .ToLocalChecked()
18383 ->Run(env.local())
18384 .ToLocalChecked();
18385 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
18386 env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked());
18387 CHECK_EQ(0,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName(
)))), "0" " " "==" " " "strcmp(\"foo.bar.baz\", *v8::String::Utf8Value(f->GetInferredName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18388, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18388 strcmp("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName(
)))), "0" " " "==" " " "strcmp(\"foo.bar.baz\", *v8::String::Utf8Value(f->GetInferredName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18388, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18389}
18390
18391
18392THREADED_TEST(FunctionGetDebugName)static void TestFunctionGetDebugName(); RegisterThreadedTest register_FunctionGetDebugName
(TestFunctionGetDebugName, "FunctionGetDebugName"); static void
TestFunctionGetDebugName(); CcTest register_test_FunctionGetDebugName
(TestFunctionGetDebugName, "../test/cctest/test-api.cc", "FunctionGetDebugName"
, __null, true, true); static void TestFunctionGetDebugName()
{
18393 LocalContext env;
18394 v8::HandleScope scope(env->GetIsolate());
18395 const char* code =
18396 "var error = false;"
18397 "function a() { this.x = 1; };"
18398 "a.displayName = 'display_a';"
18399 "var b = (function() {"
18400 " var f = function() { this.x = 2; };"
18401 " f.displayName = 'display_b';"
18402 " return f;"
18403 "})();"
18404 "var c = function() {};"
18405 "c.__defineGetter__('displayName', function() {"
18406 " error = true;"
18407 " throw new Error();"
18408 "});"
18409 "function d() {};"
18410 "d.__defineGetter__('displayName', function() {"
18411 " error = true;"
18412 " return 'wrong_display_name';"
18413 "});"
18414 "function e() {};"
18415 "e.displayName = 'wrong_display_name';"
18416 "e.__defineSetter__('displayName', function() {"
18417 " error = true;"
18418 " throw new Error();"
18419 "});"
18420 "function f() {};"
18421 "f.displayName = { 'foo': 6, toString: function() {"
18422 " error = true;"
18423 " return 'wrong_display_name';"
18424 "}};"
18425 "var g = function() {"
18426 " arguments.callee.displayName = 'set_in_runtime';"
18427 "}; g();"
18428 "var h = function() {};"
18429 "h.displayName = 'displayName';"
18430 "Object.defineProperty(h, 'name', { value: 'function.name' });"
18431 "var i = function() {};"
18432 "i.displayName = 239;"
18433 "Object.defineProperty(i, 'name', { value: 'function.name' });"
18434 "var j = function() {};"
18435 "Object.defineProperty(j, 'name', { value: 'function.name' });"
18436 "var foo = { bar : { baz : function() {}}}; var k = foo.bar.baz;";
18437 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
18438 v8::Script::Compile(env.local(), v8_str(code), &origin)
18439 .ToLocalChecked()
18440 ->Run(env.local())
18441 .ToLocalChecked();
18442 v8::Local<v8::Value> error =
18443 env->Global()->Get(env.local(), v8_str("error")).ToLocalChecked();
18444 CHECK_EQ(false, error->BooleanValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (error->BooleanValue(env.local()).FromJust()), "false" " "
"==" " " "error->BooleanValue(env.local()).FromJust()")) {
V8_Fatal("../test/cctest/test-api.cc", 18444, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18445 const char* functions[] = {"a", "display_a",
18446 "b", "display_b",
18447 "c", "c",
18448 "d", "d",
18449 "e", "e",
18450 "f", "f",
18451 "g", "set_in_runtime",
18452 "h", "displayName",
18453 "i", "function.name",
18454 "j", "function.name",
18455 "k", "foo.bar.baz"};
18456 for (size_t i = 0; i < sizeof(functions) / sizeof(functions[0]) / 2; ++i) {
18457 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
18458 env->Global()
18459 ->Get(env.local(),
18460 v8::String::NewFromUtf8(env->GetIsolate(), functions[i * 2],
18461 v8::NewStringType::kNormal)
18462 .ToLocalChecked())
18463 .ToLocalChecked());
18464 CHECK_EQ(0, strcmp(functions[i * 2 + 1],do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(functions[i * 2 + 1], *v8::String::Utf8Value(f->GetDebugName
()))), "0" " " "==" " " "strcmp(functions[i * 2 + 1], *v8::String::Utf8Value(f->GetDebugName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18465, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18465 *v8::String::Utf8Value(f->GetDebugName())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(functions[i * 2 + 1], *v8::String::Utf8Value(f->GetDebugName
()))), "0" " " "==" " " "strcmp(functions[i * 2 + 1], *v8::String::Utf8Value(f->GetDebugName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18465, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18466 }
18467}
18468
18469
18470THREADED_TEST(FunctionGetDisplayName)static void TestFunctionGetDisplayName(); RegisterThreadedTest
register_FunctionGetDisplayName(TestFunctionGetDisplayName, "FunctionGetDisplayName"
); static void TestFunctionGetDisplayName(); CcTest register_test_FunctionGetDisplayName
(TestFunctionGetDisplayName, "../test/cctest/test-api.cc", "FunctionGetDisplayName"
, __null, true, true); static void TestFunctionGetDisplayName
()
{
18471 LocalContext env;
18472 v8::HandleScope scope(env->GetIsolate());
18473 const char* code = "var error = false;"
18474 "function a() { this.x = 1; };"
18475 "a.displayName = 'display_a';"
18476 "var b = (function() {"
18477 " var f = function() { this.x = 2; };"
18478 " f.displayName = 'display_b';"
18479 " return f;"
18480 "})();"
18481 "var c = function() {};"
18482 "c.__defineGetter__('displayName', function() {"
18483 " error = true;"
18484 " throw new Error();"
18485 "});"
18486 "function d() {};"
18487 "d.__defineGetter__('displayName', function() {"
18488 " error = true;"
18489 " return 'wrong_display_name';"
18490 "});"
18491 "function e() {};"
18492 "e.displayName = 'wrong_display_name';"
18493 "e.__defineSetter__('displayName', function() {"
18494 " error = true;"
18495 " throw new Error();"
18496 "});"
18497 "function f() {};"
18498 "f.displayName = { 'foo': 6, toString: function() {"
18499 " error = true;"
18500 " return 'wrong_display_name';"
18501 "}};"
18502 "var g = function() {"
18503 " arguments.callee.displayName = 'set_in_runtime';"
18504 "}; g();";
18505 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
18506 v8::Script::Compile(env.local(), v8_str(code), &origin)
18507 .ToLocalChecked()
18508 ->Run(env.local())
18509 .ToLocalChecked();
18510 v8::Local<v8::Value> error =
18511 env->Global()->Get(env.local(), v8_str("error")).ToLocalChecked();
18512 v8::Local<v8::Function> a = v8::Local<v8::Function>::Cast(
18513 env->Global()->Get(env.local(), v8_str("a")).ToLocalChecked());
18514 v8::Local<v8::Function> b = v8::Local<v8::Function>::Cast(
18515 env->Global()->Get(env.local(), v8_str("b")).ToLocalChecked());
18516 v8::Local<v8::Function> c = v8::Local<v8::Function>::Cast(
18517 env->Global()->Get(env.local(), v8_str("c")).ToLocalChecked());
18518 v8::Local<v8::Function> d = v8::Local<v8::Function>::Cast(
18519 env->Global()->Get(env.local(), v8_str("d")).ToLocalChecked());
18520 v8::Local<v8::Function> e = v8::Local<v8::Function>::Cast(
18521 env->Global()->Get(env.local(), v8_str("e")).ToLocalChecked());
18522 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
18523 env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked());
18524 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
18525 env->Global()->Get(env.local(), v8_str("g")).ToLocalChecked());
18526 CHECK_EQ(false, error->BooleanValue(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (error->BooleanValue(env.local()).FromJust()), "false" " "
"==" " " "error->BooleanValue(env.local()).FromJust()")) {
V8_Fatal("../test/cctest/test-api.cc", 18526, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18527 CHECK_EQ(0, strcmp("display_a", *v8::String::Utf8Value(a->GetDisplayName())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("display_a", *v8::String::Utf8Value(a->GetDisplayName()))
), "0" " " "==" " " "strcmp(\"display_a\", *v8::String::Utf8Value(a->GetDisplayName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18527, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18528 CHECK_EQ(0, strcmp("display_b", *v8::String::Utf8Value(b->GetDisplayName())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("display_b", *v8::String::Utf8Value(b->GetDisplayName()))
), "0" " " "==" " " "strcmp(\"display_b\", *v8::String::Utf8Value(b->GetDisplayName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18528, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18529 CHECK(c->GetDisplayName()->IsUndefined())do { if ((__builtin_expect(!!(!(c->GetDisplayName()->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18529, "Check failed: %s."
, "c->GetDisplayName()->IsUndefined()"); } } while (0)
;
18530 CHECK(d->GetDisplayName()->IsUndefined())do { if ((__builtin_expect(!!(!(d->GetDisplayName()->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18530, "Check failed: %s."
, "d->GetDisplayName()->IsUndefined()"); } } while (0)
;
18531 CHECK(e->GetDisplayName()->IsUndefined())do { if ((__builtin_expect(!!(!(e->GetDisplayName()->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18531, "Check failed: %s."
, "e->GetDisplayName()->IsUndefined()"); } } while (0)
;
18532 CHECK(f->GetDisplayName()->IsUndefined())do { if ((__builtin_expect(!!(!(f->GetDisplayName()->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 18532, "Check failed: %s."
, "f->GetDisplayName()->IsUndefined()"); } } while (0)
;
18533 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("set_in_runtime", *v8::String::Utf8Value(g->GetDisplayName
()))), "0" " " "==" " " "strcmp(\"set_in_runtime\", *v8::String::Utf8Value(g->GetDisplayName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18534, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18534 0, strcmp("set_in_runtime", *v8::String::Utf8Value(g->GetDisplayName())))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("set_in_runtime", *v8::String::Utf8Value(g->GetDisplayName
()))), "0" " " "==" " " "strcmp(\"set_in_runtime\", *v8::String::Utf8Value(g->GetDisplayName()))"
)) { V8_Fatal("../test/cctest/test-api.cc", 18534, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18535}
18536
18537
18538THREADED_TEST(ScriptLineNumber)static void TestScriptLineNumber(); RegisterThreadedTest register_ScriptLineNumber
(TestScriptLineNumber, "ScriptLineNumber"); static void TestScriptLineNumber
(); CcTest register_test_ScriptLineNumber(TestScriptLineNumber
, "../test/cctest/test-api.cc", "ScriptLineNumber", __null, true
, true); static void TestScriptLineNumber()
{
18539 LocalContext env;
18540 v8::HandleScope scope(env->GetIsolate());
18541 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
18542 v8::Local<v8::String> script = v8_str("function f() {}\n\nfunction g() {}");
18543 v8::Script::Compile(env.local(), script, &origin)
18544 .ToLocalChecked()
18545 ->Run(env.local())
18546 .ToLocalChecked();
18547 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
18548 env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked());
18549 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
18550 env->Global()->Get(env.local(), v8_str("g")).ToLocalChecked());
18551 CHECK_EQ(0, f->GetScriptLineNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (f
->GetScriptLineNumber()), "0" " " "==" " " "f->GetScriptLineNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18551, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18552 CHECK_EQ(2, g->GetScriptLineNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (g
->GetScriptLineNumber()), "2" " " "==" " " "g->GetScriptLineNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18552, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18553}
18554
18555
18556THREADED_TEST(ScriptColumnNumber)static void TestScriptColumnNumber(); RegisterThreadedTest register_ScriptColumnNumber
(TestScriptColumnNumber, "ScriptColumnNumber"); static void TestScriptColumnNumber
(); CcTest register_test_ScriptColumnNumber(TestScriptColumnNumber
, "../test/cctest/test-api.cc", "ScriptColumnNumber", __null,
true, true); static void TestScriptColumnNumber()
{
18557 LocalContext env;
18558 v8::Isolate* isolate = env->GetIsolate();
18559 v8::HandleScope scope(isolate);
18560 v8::ScriptOrigin origin =
18561 v8::ScriptOrigin(v8_str("test"), v8::Integer::New(isolate, 3),
18562 v8::Integer::New(isolate, 2));
18563 v8::Local<v8::String> script =
18564 v8_str("function foo() {}\n\n function bar() {}");
18565 v8::Script::Compile(env.local(), script, &origin)
18566 .ToLocalChecked()
18567 ->Run(env.local())
18568 .ToLocalChecked();
18569 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
18570 env->Global()->Get(env.local(), v8_str("foo")).ToLocalChecked());
18571 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
18572 env->Global()->Get(env.local(), v8_str("bar")).ToLocalChecked());
18573 CHECK_EQ(14, foo->GetScriptColumnNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (14), (
foo->GetScriptColumnNumber()), "14" " " "==" " " "foo->GetScriptColumnNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18573, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18574 CHECK_EQ(17, bar->GetScriptColumnNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (17), (
bar->GetScriptColumnNumber()), "17" " " "==" " " "bar->GetScriptColumnNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18574, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18575}
18576
18577
18578THREADED_TEST(FunctionIsBuiltin)static void TestFunctionIsBuiltin(); RegisterThreadedTest register_FunctionIsBuiltin
(TestFunctionIsBuiltin, "FunctionIsBuiltin"); static void TestFunctionIsBuiltin
(); CcTest register_test_FunctionIsBuiltin(TestFunctionIsBuiltin
, "../test/cctest/test-api.cc", "FunctionIsBuiltin", __null, true
, true); static void TestFunctionIsBuiltin()
{
18579 LocalContext env;
18580 v8::Isolate* isolate = env->GetIsolate();
18581 v8::HandleScope scope(isolate);
18582 v8::Local<v8::Function> f;
18583 f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor"));
18584 CHECK(f->IsBuiltin())do { if ((__builtin_expect(!!(!(f->IsBuiltin())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 18584, "Check failed: %s.", "f->IsBuiltin()"
); } } while (0)
;
18585 f = v8::Local<v8::Function>::Cast(CompileRun("Object"));
18586 CHECK(f->IsBuiltin())do { if ((__builtin_expect(!!(!(f->IsBuiltin())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 18586, "Check failed: %s.", "f->IsBuiltin()"
); } } while (0)
;
18587 f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__"));
18588 CHECK(f->IsBuiltin())do { if ((__builtin_expect(!!(!(f->IsBuiltin())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 18588, "Check failed: %s.", "f->IsBuiltin()"
); } } while (0)
;
18589 f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString"));
18590 CHECK(f->IsBuiltin())do { if ((__builtin_expect(!!(!(f->IsBuiltin())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 18590, "Check failed: %s.", "f->IsBuiltin()"
); } } while (0)
;
18591 f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;"));
18592 CHECK(!f->IsBuiltin())do { if ((__builtin_expect(!!(!(!f->IsBuiltin())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 18592, "Check failed: %s.", "!f->IsBuiltin()"
); } } while (0)
;
18593}
18594
18595
18596THREADED_TEST(FunctionGetScriptId)static void TestFunctionGetScriptId(); RegisterThreadedTest register_FunctionGetScriptId
(TestFunctionGetScriptId, "FunctionGetScriptId"); static void
TestFunctionGetScriptId(); CcTest register_test_FunctionGetScriptId
(TestFunctionGetScriptId, "../test/cctest/test-api.cc", "FunctionGetScriptId"
, __null, true, true); static void TestFunctionGetScriptId()
{
18597 LocalContext env;
18598 v8::Isolate* isolate = env->GetIsolate();
18599 v8::HandleScope scope(isolate);
18600 v8::ScriptOrigin origin =
18601 v8::ScriptOrigin(v8_str("test"), v8::Integer::New(isolate, 3),
18602 v8::Integer::New(isolate, 2));
18603 v8::Local<v8::String> scriptSource =
18604 v8_str("function foo() {}\n\n function bar() {}");
18605 v8::Local<v8::Script> script(
18606 v8::Script::Compile(env.local(), scriptSource, &origin).ToLocalChecked());
18607 script->Run(env.local()).ToLocalChecked();
18608 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
18609 env->Global()->Get(env.local(), v8_str("foo")).ToLocalChecked());
18610 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
18611 env->Global()->Get(env.local(), v8_str("bar")).ToLocalChecked());
18612 CHECK_EQ(script->GetUnboundScript()->GetId(), foo->ScriptId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (script
->GetUnboundScript()->GetId()), (foo->ScriptId()), "script->GetUnboundScript()->GetId()"
" " "==" " " "foo->ScriptId()")) { V8_Fatal("../test/cctest/test-api.cc"
, 18612, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18613 CHECK_EQ(script->GetUnboundScript()->GetId(), bar->ScriptId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (script
->GetUnboundScript()->GetId()), (bar->ScriptId()), "script->GetUnboundScript()->GetId()"
" " "==" " " "bar->ScriptId()")) { V8_Fatal("../test/cctest/test-api.cc"
, 18613, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18614}
18615
18616
18617THREADED_TEST(FunctionGetBoundFunction)static void TestFunctionGetBoundFunction(); RegisterThreadedTest
register_FunctionGetBoundFunction(TestFunctionGetBoundFunction
, "FunctionGetBoundFunction"); static void TestFunctionGetBoundFunction
(); CcTest register_test_FunctionGetBoundFunction(TestFunctionGetBoundFunction
, "../test/cctest/test-api.cc", "FunctionGetBoundFunction", __null
, true, true); static void TestFunctionGetBoundFunction()
{
18618 LocalContext env;
18619 v8::HandleScope scope(env->GetIsolate());
18620 v8::ScriptOrigin origin = v8::ScriptOrigin(v8_str("test"));
18621 v8::Local<v8::String> script = v8_str(
18622 "var a = new Object();\n"
18623 "a.x = 1;\n"
18624 "function f () { return this.x };\n"
18625 "var g = f.bind(a);\n"
18626 "var b = g();");
18627 v8::Script::Compile(env.local(), script, &origin)
18628 .ToLocalChecked()
18629 ->Run(env.local())
18630 .ToLocalChecked();
18631 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
18632 env->Global()->Get(env.local(), v8_str("f")).ToLocalChecked());
18633 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
18634 env->Global()->Get(env.local(), v8_str("g")).ToLocalChecked());
18635 CHECK(g->GetBoundFunction()->IsFunction())do { if ((__builtin_expect(!!(!(g->GetBoundFunction()->
IsFunction())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
18635, "Check failed: %s.", "g->GetBoundFunction()->IsFunction()"
); } } while (0)
;
18636 Local<v8::Function> original_function = Local<v8::Function>::Cast(
18637 g->GetBoundFunction());
18638 CHECK(f->GetName()do { if ((__builtin_expect(!!(!(f->GetName() ->Equals(env
.local(), original_function->GetName()) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 18640, "Check failed: %s."
, "f->GetName() ->Equals(env.local(), original_function->GetName()) .FromJust()"
); } } while (0)
18639 ->Equals(env.local(), original_function->GetName())do { if ((__builtin_expect(!!(!(f->GetName() ->Equals(env
.local(), original_function->GetName()) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 18640, "Check failed: %s."
, "f->GetName() ->Equals(env.local(), original_function->GetName()) .FromJust()"
); } } while (0)
18640 .FromJust())do { if ((__builtin_expect(!!(!(f->GetName() ->Equals(env
.local(), original_function->GetName()) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 18640, "Check failed: %s."
, "f->GetName() ->Equals(env.local(), original_function->GetName()) .FromJust()"
); } } while (0)
;
18641 CHECK_EQ(f->GetScriptLineNumber(), original_function->GetScriptLineNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (f->
GetScriptLineNumber()), (original_function->GetScriptLineNumber
()), "f->GetScriptLineNumber()" " " "==" " " "original_function->GetScriptLineNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18641, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18642 CHECK_EQ(f->GetScriptColumnNumber(),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (f->
GetScriptColumnNumber()), (original_function->GetScriptColumnNumber
()), "f->GetScriptColumnNumber()" " " "==" " " "original_function->GetScriptColumnNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18643, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18643 original_function->GetScriptColumnNumber())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (f->
GetScriptColumnNumber()), (original_function->GetScriptColumnNumber
()), "f->GetScriptColumnNumber()" " " "==" " " "original_function->GetScriptColumnNumber()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18643, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18644}
18645
18646
18647static void GetterWhichReturns42(
18648 Local<String> name,
18649 const v8::PropertyCallbackInfo<v8::Value>& info) {
18650 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*info.This
())->IsJSObject())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18650, "Check failed: %s.", "v8::Utils::OpenHandle(*info.This())->IsJSObject()"
); } } while (0)
;
18651 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*info.Holder
())->IsJSObject())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18651, "Check failed: %s.", "v8::Utils::OpenHandle(*info.Holder())->IsJSObject()"
); } } while (0)
;
18652 info.GetReturnValue().Set(v8_num(42));
18653}
18654
18655
18656static void SetterWhichSetsYOnThisTo23(
18657 Local<String> name,
18658 Local<Value> value,
18659 const v8::PropertyCallbackInfo<void>& info) {
18660 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*info.This
())->IsJSObject())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18660, "Check failed: %s.", "v8::Utils::OpenHandle(*info.This())->IsJSObject()"
); } } while (0)
;
18661 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*info.Holder
())->IsJSObject())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18661, "Check failed: %s.", "v8::Utils::OpenHandle(*info.Holder())->IsJSObject()"
); } } while (0)
;
18662 Local<Object>::Cast(info.This())
18663 ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23))
18664 .FromJust();
18665}
18666
18667
18668void FooGetInterceptor(Local<Name> name,
18669 const v8::PropertyCallbackInfo<v8::Value>& info) {
18670 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*info.This
())->IsJSObject())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18670, "Check failed: %s.", "v8::Utils::OpenHandle(*info.This())->IsJSObject()"
); } } while (0)
;
18671 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*info.Holder
())->IsJSObject())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18671, "Check failed: %s.", "v8::Utils::OpenHandle(*info.Holder())->IsJSObject()"
); } } while (0)
;
18672 if (!name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("foo"))
18673 .FromJust()) {
18674 return;
18675 }
18676 info.GetReturnValue().Set(v8_num(42));
18677}
18678
18679
18680void FooSetInterceptor(Local<Name> name, Local<Value> value,
18681 const v8::PropertyCallbackInfo<v8::Value>& info) {
18682 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*info.This
())->IsJSObject())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18682, "Check failed: %s.", "v8::Utils::OpenHandle(*info.This())->IsJSObject()"
); } } while (0)
;
18683 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*info.Holder
())->IsJSObject())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18683, "Check failed: %s.", "v8::Utils::OpenHandle(*info.Holder())->IsJSObject()"
); } } while (0)
;
18684 if (!name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("foo"))
18685 .FromJust()) {
18686 return;
18687 }
18688 Local<Object>::Cast(info.This())
18689 ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23))
18690 .FromJust();
18691 info.GetReturnValue().Set(v8_num(23));
18692}
18693
18694
18695TEST(SetterOnConstructorPrototype)static void TestSetterOnConstructorPrototype(); CcTest register_test_SetterOnConstructorPrototype
(TestSetterOnConstructorPrototype, "../test/cctest/test-api.cc"
, "SetterOnConstructorPrototype", __null, true, true); static
void TestSetterOnConstructorPrototype()
{
18696 v8::Isolate* isolate = CcTest::isolate();
18697 v8::HandleScope scope(isolate);
18698 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
18699 templ->SetAccessor(v8_str("x"), GetterWhichReturns42,
18700 SetterWhichSetsYOnThisTo23);
18701 LocalContext context;
18702 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18705, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18703 ->Set(context.local(), v8_str("P"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18705, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18704 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18705, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18705 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18705, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
18706 CompileRun("function C1() {"
18707 " this.x = 23;"
18708 "};"
18709 "C1.prototype = P;"
18710 "function C2() {"
18711 " this.x = 23"
18712 "};"
18713 "C2.prototype = { };"
18714 "C2.prototype.__proto__ = P;");
18715
18716 v8::Local<v8::Script> script;
18717 script = v8_compile("new C1();");
18718 for (int i = 0; i < 10; i++) {
18719 v8::Local<v8::Object> c1 = v8::Local<v8::Object>::Cast(
18720 script->Run(context.local()).ToLocalChecked());
18721 CHECK_EQ(42, c1->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18724, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18722 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18724, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18723 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18724, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18724 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18724, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18725 CHECK_EQ(23, c1->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18728, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18726 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18728, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18727 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18728, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18728 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18728, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18729 }
18730
18731 script = v8_compile("new C2();");
18732 for (int i = 0; i < 10; i++) {
18733 v8::Local<v8::Object> c2 = v8::Local<v8::Object>::Cast(
18734 script->Run(context.local()).ToLocalChecked());
18735 CHECK_EQ(42, c2->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c2->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c2->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18738, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18736 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c2->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c2->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18738, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18737 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c2->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c2->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18738, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18738 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c2->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c2->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18738, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18739 CHECK_EQ(23, c2->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c2->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c2->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18742, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18740 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c2->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c2->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18742, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18741 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c2->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c2->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18742, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18742 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c2->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c2->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18742, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18743 }
18744}
18745
18746
18747static void NamedPropertyGetterWhichReturns42(
18748 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
18749 info.GetReturnValue().Set(v8_num(42));
18750}
18751
18752
18753static void NamedPropertySetterWhichSetsYOnThisTo23(
18754 Local<Name> name, Local<Value> value,
18755 const v8::PropertyCallbackInfo<v8::Value>& info) {
18756 if (name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("x"))
18757 .FromJust()) {
18758 Local<Object>::Cast(info.This())
18759 ->Set(info.GetIsolate()->GetCurrentContext(), v8_str("y"), v8_num(23))
18760 .FromJust();
18761 }
18762}
18763
18764
18765THREADED_TEST(InterceptorOnConstructorPrototype)static void TestInterceptorOnConstructorPrototype(); RegisterThreadedTest
register_InterceptorOnConstructorPrototype(TestInterceptorOnConstructorPrototype
, "InterceptorOnConstructorPrototype"); static void TestInterceptorOnConstructorPrototype
(); CcTest register_test_InterceptorOnConstructorPrototype(TestInterceptorOnConstructorPrototype
, "../test/cctest/test-api.cc", "InterceptorOnConstructorPrototype"
, __null, true, true); static void TestInterceptorOnConstructorPrototype
()
{
18766 v8::Isolate* isolate = CcTest::isolate();
18767 v8::HandleScope scope(isolate);
18768 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
18769 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
18770 NamedPropertyGetterWhichReturns42,
18771 NamedPropertySetterWhichSetsYOnThisTo23));
18772 LocalContext context;
18773 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18776, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18774 ->Set(context.local(), v8_str("P"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18776, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18775 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18776, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18776 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18776, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
18777 CompileRun("function C1() {"
18778 " this.x = 23;"
18779 "};"
18780 "C1.prototype = P;"
18781 "function C2() {"
18782 " this.x = 23"
18783 "};"
18784 "C2.prototype = { };"
18785 "C2.prototype.__proto__ = P;");
18786
18787 v8::Local<v8::Script> script;
18788 script = v8_compile("new C1();");
18789 for (int i = 0; i < 10; i++) {
18790 v8::Local<v8::Object> c1 = v8::Local<v8::Object>::Cast(
18791 script->Run(context.local()).ToLocalChecked());
18792 CHECK_EQ(23, c1->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18795, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18793 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18795, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18794 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18795, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18795 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18795, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18796 CHECK_EQ(42, c1->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18799, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18797 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18799, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18798 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18799, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18799 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18799, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18800 }
18801
18802 script = v8_compile("new C2();");
18803 for (int i = 0; i < 10; i++) {
18804 v8::Local<v8::Object> c2 = v8::Local<v8::Object>::Cast(
18805 script->Run(context.local()).ToLocalChecked());
18806 CHECK_EQ(23, c2->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c2->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c2->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18809, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18807 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c2->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c2->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18809, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18808 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c2->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c2->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18809, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18809 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c2->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c2->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18809, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18810 CHECK_EQ(42, c2->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c2->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c2->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18813, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18811 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c2->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c2->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18813, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18812 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c2->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c2->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18813, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18813 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c2->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c2->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18813, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18814 }
18815}
18816
18817
18818TEST(Regress618)static void TestRegress618(); CcTest register_test_Regress618
(TestRegress618, "../test/cctest/test-api.cc", "Regress618", __null
, true, true); static void TestRegress618()
{
18819 const char* source = "function C1() {"
18820 " this.x = 23;"
18821 "};"
18822 "C1.prototype = P;";
18823
18824 LocalContext context;
18825 v8::Isolate* isolate = context->GetIsolate();
18826 v8::HandleScope scope(isolate);
18827 v8::Local<v8::Script> script;
18828
18829 // Use a simple object as prototype.
18830 v8::Local<v8::Object> prototype = v8::Object::New(isolate);
18831 prototype->Set(context.local(), v8_str("y"), v8_num(42)).FromJust();
18832 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), prototype) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 18834, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"P\"), prototype) .FromJust()"
); } } while (0)
18833 ->Set(context.local(), v8_str("P"), prototype)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), prototype) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 18834, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"P\"), prototype) .FromJust()"
); } } while (0)
18834 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), prototype) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 18834, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"P\"), prototype) .FromJust()"
); } } while (0)
;
18835
18836 // This compile will add the code to the compilation cache.
18837 CompileRun(source);
18838
18839 script = v8_compile("new C1();");
18840 // Allow enough iterations for the inobject slack tracking logic
18841 // to finalize instance size and install the fast construct stub.
18842 for (int i = 0; i < 256; i++) {
18843 v8::Local<v8::Object> c1 = v8::Local<v8::Object>::Cast(
18844 script->Run(context.local()).ToLocalChecked());
18845 CHECK_EQ(23, c1->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18848, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18846 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18848, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18847 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18848, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18848 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18848, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18849 CHECK_EQ(42, c1->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18852, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18850 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18852, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18851 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18852, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18852 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18852, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18853 }
18854
18855 // Use an API object with accessors as prototype.
18856 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
18857 templ->SetAccessor(v8_str("x"), GetterWhichReturns42,
18858 SetterWhichSetsYOnThisTo23);
18859 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18862, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18860 ->Set(context.local(), v8_str("P"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18862, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18861 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18862, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
18862 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 18862, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
18863
18864 // This compile will get the code from the compilation cache.
18865 CompileRun(source);
18866
18867 script = v8_compile("new C1();");
18868 for (int i = 0; i < 10; i++) {
18869 v8::Local<v8::Object> c1 = v8::Local<v8::Object>::Cast(
18870 script->Run(context.local()).ToLocalChecked());
18871 CHECK_EQ(42, c1->Get(context.local(), v8_str("x"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18874, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18872 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18874, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18873 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18874, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18874 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
c1->Get(context.local(), v8_str("x")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "42" " " "==" " " "c1->Get(context.local(), v8_str(\"x\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18874, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18875 CHECK_EQ(23, c1->Get(context.local(), v8_str("y"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18878, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18876 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18878, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18877 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18878, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
18878 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (23), (
c1->Get(context.local(), v8_str("y")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "23" " " "==" " " "c1->Get(context.local(), v8_str(\"y\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 18878, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18879 }
18880}
18881
18882v8::Isolate* gc_callbacks_isolate = NULL__null;
18883int prologue_call_count = 0;
18884int epilogue_call_count = 0;
18885int prologue_call_count_second = 0;
18886int epilogue_call_count_second = 0;
18887int prologue_call_count_alloc = 0;
18888int epilogue_call_count_alloc = 0;
18889
18890void PrologueCallback(v8::Isolate* isolate,
18891 v8::GCType,
18892 v8::GCCallbackFlags flags) {
18893 CHECK_EQ(flags, v8::kNoGCCallbackFlags)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (flags)
, (v8::kNoGCCallbackFlags), "flags" " " "==" " " "v8::kNoGCCallbackFlags"
)) { V8_Fatal("../test/cctest/test-api.cc", 18893, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18894 CHECK_EQ(gc_callbacks_isolate, isolate)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (gc_callbacks_isolate
), (isolate), "gc_callbacks_isolate" " " "==" " " "isolate"))
{ V8_Fatal("../test/cctest/test-api.cc", 18894, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18895 ++prologue_call_count;
18896}
18897
18898void EpilogueCallback(v8::Isolate* isolate,
18899 v8::GCType,
18900 v8::GCCallbackFlags flags) {
18901 CHECK_EQ(flags, v8::kNoGCCallbackFlags)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (flags)
, (v8::kNoGCCallbackFlags), "flags" " " "==" " " "v8::kNoGCCallbackFlags"
)) { V8_Fatal("../test/cctest/test-api.cc", 18901, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18902 CHECK_EQ(gc_callbacks_isolate, isolate)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (gc_callbacks_isolate
), (isolate), "gc_callbacks_isolate" " " "==" " " "isolate"))
{ V8_Fatal("../test/cctest/test-api.cc", 18902, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18903 ++epilogue_call_count;
18904}
18905
18906
18907void PrologueCallbackSecond(v8::Isolate* isolate,
18908 v8::GCType,
18909 v8::GCCallbackFlags flags) {
18910 CHECK_EQ(flags, v8::kNoGCCallbackFlags)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (flags)
, (v8::kNoGCCallbackFlags), "flags" " " "==" " " "v8::kNoGCCallbackFlags"
)) { V8_Fatal("../test/cctest/test-api.cc", 18910, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18911 CHECK_EQ(gc_callbacks_isolate, isolate)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (gc_callbacks_isolate
), (isolate), "gc_callbacks_isolate" " " "==" " " "isolate"))
{ V8_Fatal("../test/cctest/test-api.cc", 18911, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18912 ++prologue_call_count_second;
18913}
18914
18915
18916void EpilogueCallbackSecond(v8::Isolate* isolate,
18917 v8::GCType,
18918 v8::GCCallbackFlags flags) {
18919 CHECK_EQ(flags, v8::kNoGCCallbackFlags)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (flags)
, (v8::kNoGCCallbackFlags), "flags" " " "==" " " "v8::kNoGCCallbackFlags"
)) { V8_Fatal("../test/cctest/test-api.cc", 18919, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18920 CHECK_EQ(gc_callbacks_isolate, isolate)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (gc_callbacks_isolate
), (isolate), "gc_callbacks_isolate" " " "==" " " "isolate"))
{ V8_Fatal("../test/cctest/test-api.cc", 18920, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18921 ++epilogue_call_count_second;
18922}
18923
18924
18925void PrologueCallbackAlloc(v8::Isolate* isolate,
18926 v8::GCType,
18927 v8::GCCallbackFlags flags) {
18928 v8::HandleScope scope(isolate);
18929
18930 CHECK_EQ(flags, v8::kNoGCCallbackFlags)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (flags)
, (v8::kNoGCCallbackFlags), "flags" " " "==" " " "v8::kNoGCCallbackFlags"
)) { V8_Fatal("../test/cctest/test-api.cc", 18930, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18931 CHECK_EQ(gc_callbacks_isolate, isolate)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (gc_callbacks_isolate
), (isolate), "gc_callbacks_isolate" " " "==" " " "isolate"))
{ V8_Fatal("../test/cctest/test-api.cc", 18931, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18932 ++prologue_call_count_alloc;
18933
18934 // Simulate full heap to see if we will reenter this callback
18935 SimulateFullSpace(CcTest::heap()->new_space());
18936
18937 Local<Object> obj = Object::New(isolate);
18938 CHECK(!obj.IsEmpty())do { if ((__builtin_expect(!!(!(!obj.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 18938, "Check failed: %s.", "!obj.IsEmpty()"
); } } while (0)
;
18939
18940 CcTest::heap()->CollectAllGarbage(
18941 i::Heap::kAbortIncrementalMarkingMask);
18942}
18943
18944
18945void EpilogueCallbackAlloc(v8::Isolate* isolate,
18946 v8::GCType,
18947 v8::GCCallbackFlags flags) {
18948 v8::HandleScope scope(isolate);
18949
18950 CHECK_EQ(flags, v8::kNoGCCallbackFlags)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (flags)
, (v8::kNoGCCallbackFlags), "flags" " " "==" " " "v8::kNoGCCallbackFlags"
)) { V8_Fatal("../test/cctest/test-api.cc", 18950, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18951 CHECK_EQ(gc_callbacks_isolate, isolate)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (gc_callbacks_isolate
), (isolate), "gc_callbacks_isolate" " " "==" " " "isolate"))
{ V8_Fatal("../test/cctest/test-api.cc", 18951, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
18952 ++epilogue_call_count_alloc;
18953
18954 // Simulate full heap to see if we will reenter this callback
18955 SimulateFullSpace(CcTest::heap()->new_space());
18956
18957 Local<Object> obj = Object::New(isolate);
18958 CHECK(!obj.IsEmpty())do { if ((__builtin_expect(!!(!(!obj.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 18958, "Check failed: %s.", "!obj.IsEmpty()"
); } } while (0)
;
18959
18960 CcTest::heap()->CollectAllGarbage(
18961 i::Heap::kAbortIncrementalMarkingMask);
18962}
18963
18964
18965TEST(GCCallbacksOld)static void TestGCCallbacksOld(); CcTest register_test_GCCallbacksOld
(TestGCCallbacksOld, "../test/cctest/test-api.cc", "GCCallbacksOld"
, __null, true, true); static void TestGCCallbacksOld()
{
18966 LocalContext context;
18967
18968 gc_callbacks_isolate = context->GetIsolate();
18969
18970 context->GetIsolate()->AddGCPrologueCallback(PrologueCallback);
18971 context->GetIsolate()->AddGCEpilogueCallback(EpilogueCallback);
18972 CHECK_EQ(0, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (prologue_call_count
), "0" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18972, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18973 CHECK_EQ(0, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (epilogue_call_count
), "0" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18973, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18974 CcTest::heap()->CollectAllGarbage();
18975 CHECK_EQ(1, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (prologue_call_count
), "1" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18975, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18976 CHECK_EQ(1, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (epilogue_call_count
), "1" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18976, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18977 context->GetIsolate()->AddGCPrologueCallback(PrologueCallbackSecond);
18978 context->GetIsolate()->AddGCEpilogueCallback(EpilogueCallbackSecond);
18979 CcTest::heap()->CollectAllGarbage();
18980 CHECK_EQ(2, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count
), "2" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18980, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18981 CHECK_EQ(2, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count
), "2" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18981, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18982 CHECK_EQ(1, prologue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (prologue_call_count_second
), "1" " " "==" " " "prologue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 18982, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18983 CHECK_EQ(1, epilogue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (epilogue_call_count_second
), "1" " " "==" " " "epilogue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 18983, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18984 context->GetIsolate()->RemoveGCPrologueCallback(PrologueCallback);
18985 context->GetIsolate()->RemoveGCEpilogueCallback(EpilogueCallback);
18986 CcTest::heap()->CollectAllGarbage();
18987 CHECK_EQ(2, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count
), "2" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18987, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18988 CHECK_EQ(2, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count
), "2" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18988, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18989 CHECK_EQ(2, prologue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count_second
), "2" " " "==" " " "prologue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 18989, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18990 CHECK_EQ(2, epilogue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count_second
), "2" " " "==" " " "epilogue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 18990, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18991 context->GetIsolate()->RemoveGCPrologueCallback(PrologueCallbackSecond);
18992 context->GetIsolate()->RemoveGCEpilogueCallback(EpilogueCallbackSecond);
18993 CcTest::heap()->CollectAllGarbage();
18994 CHECK_EQ(2, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count
), "2" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18994, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18995 CHECK_EQ(2, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count
), "2" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 18995, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
18996 CHECK_EQ(2, prologue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count_second
), "2" " " "==" " " "prologue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 18996, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18997 CHECK_EQ(2, epilogue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count_second
), "2" " " "==" " " "epilogue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 18997, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
18998}
18999
19000
19001TEST(GCCallbacks)static void TestGCCallbacks(); CcTest register_test_GCCallbacks
(TestGCCallbacks, "../test/cctest/test-api.cc", "GCCallbacks"
, __null, true, true); static void TestGCCallbacks()
{
19002 LocalContext context;
19003 v8::Isolate* isolate = context->GetIsolate();
19004 gc_callbacks_isolate = isolate;
19005 isolate->AddGCPrologueCallback(PrologueCallback);
19006 isolate->AddGCEpilogueCallback(EpilogueCallback);
19007 CHECK_EQ(0, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (prologue_call_count
), "0" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19007, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19008 CHECK_EQ(0, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (epilogue_call_count
), "0" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19008, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19009 CcTest::heap()->CollectAllGarbage();
19010 CHECK_EQ(1, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (prologue_call_count
), "1" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19010, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19011 CHECK_EQ(1, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (epilogue_call_count
), "1" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19011, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19012 isolate->AddGCPrologueCallback(PrologueCallbackSecond);
19013 isolate->AddGCEpilogueCallback(EpilogueCallbackSecond);
19014 CcTest::heap()->CollectAllGarbage();
19015 CHECK_EQ(2, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count
), "2" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19015, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19016 CHECK_EQ(2, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count
), "2" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19016, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19017 CHECK_EQ(1, prologue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (prologue_call_count_second
), "1" " " "==" " " "prologue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 19017, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19018 CHECK_EQ(1, epilogue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (epilogue_call_count_second
), "1" " " "==" " " "epilogue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 19018, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19019 isolate->RemoveGCPrologueCallback(PrologueCallback);
19020 isolate->RemoveGCEpilogueCallback(EpilogueCallback);
19021 CcTest::heap()->CollectAllGarbage();
19022 CHECK_EQ(2, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count
), "2" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19022, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19023 CHECK_EQ(2, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count
), "2" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19023, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19024 CHECK_EQ(2, prologue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count_second
), "2" " " "==" " " "prologue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 19024, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19025 CHECK_EQ(2, epilogue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count_second
), "2" " " "==" " " "epilogue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 19025, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19026 isolate->RemoveGCPrologueCallback(PrologueCallbackSecond);
19027 isolate->RemoveGCEpilogueCallback(EpilogueCallbackSecond);
19028 CcTest::heap()->CollectAllGarbage();
19029 CHECK_EQ(2, prologue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count
), "2" " " "==" " " "prologue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19029, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19030 CHECK_EQ(2, epilogue_call_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count
), "2" " " "==" " " "epilogue_call_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 19030, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19031 CHECK_EQ(2, prologue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (prologue_call_count_second
), "2" " " "==" " " "prologue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 19031, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19032 CHECK_EQ(2, epilogue_call_count_second)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (epilogue_call_count_second
), "2" " " "==" " " "epilogue_call_count_second")) { V8_Fatal
("../test/cctest/test-api.cc", 19032, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19033
19034 CHECK_EQ(0, prologue_call_count_alloc)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (prologue_call_count_alloc
), "0" " " "==" " " "prologue_call_count_alloc")) { V8_Fatal(
"../test/cctest/test-api.cc", 19034, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19035 CHECK_EQ(0, epilogue_call_count_alloc)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (epilogue_call_count_alloc
), "0" " " "==" " " "epilogue_call_count_alloc")) { V8_Fatal(
"../test/cctest/test-api.cc", 19035, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19036 isolate->AddGCPrologueCallback(PrologueCallbackAlloc);
19037 isolate->AddGCEpilogueCallback(EpilogueCallbackAlloc);
19038 CcTest::heap()->CollectAllGarbage(
19039 i::Heap::kAbortIncrementalMarkingMask);
19040 CHECK_EQ(1, prologue_call_count_alloc)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (prologue_call_count_alloc
), "1" " " "==" " " "prologue_call_count_alloc")) { V8_Fatal(
"../test/cctest/test-api.cc", 19040, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19041 CHECK_EQ(1, epilogue_call_count_alloc)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (epilogue_call_count_alloc
), "1" " " "==" " " "epilogue_call_count_alloc")) { V8_Fatal(
"../test/cctest/test-api.cc", 19041, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19042 isolate->RemoveGCPrologueCallback(PrologueCallbackAlloc);
19043 isolate->RemoveGCEpilogueCallback(EpilogueCallbackAlloc);
19044}
19045
19046
19047THREADED_TEST(TwoByteStringInOneByteCons)static void TestTwoByteStringInOneByteCons(); RegisterThreadedTest
register_TwoByteStringInOneByteCons(TestTwoByteStringInOneByteCons
, "TwoByteStringInOneByteCons"); static void TestTwoByteStringInOneByteCons
(); CcTest register_test_TwoByteStringInOneByteCons(TestTwoByteStringInOneByteCons
, "../test/cctest/test-api.cc", "TwoByteStringInOneByteCons",
__null, true, true); static void TestTwoByteStringInOneByteCons
()
{
19048 // See Chromium issue 47824.
19049 LocalContext context;
19050 v8::HandleScope scope(context->GetIsolate());
19051
19052 const char* init_code =
19053 "var str1 = 'abelspendabel';"
19054 "var str2 = str1 + str1 + str1;"
19055 "str2;";
19056 Local<Value> result = CompileRun(init_code);
19057
19058 Local<Value> indexof = CompileRun("str2.indexOf('els')");
19059 Local<Value> lastindexof = CompileRun("str2.lastIndexOf('dab')");
19060
19061 CHECK(result->IsString())do { if ((__builtin_expect(!!(!(result->IsString())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19061, "Check failed: %s."
, "result->IsString()"); } } while (0)
;
19062 i::Handle<i::String> string = v8::Utils::OpenHandle(String::Cast(*result));
19063 int length = string->length();
19064 CHECK(string->IsOneByteRepresentation())do { if ((__builtin_expect(!!(!(string->IsOneByteRepresentation
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19064, "Check failed: %s."
, "string->IsOneByteRepresentation()"); } } while (0)
;
19065
19066 i::Handle<i::String> flat_string = i::String::Flatten(string);
19067
19068 CHECK(string->IsOneByteRepresentation())do { if ((__builtin_expect(!!(!(string->IsOneByteRepresentation
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19068, "Check failed: %s."
, "string->IsOneByteRepresentation()"); } } while (0)
;
19069 CHECK(flat_string->IsOneByteRepresentation())do { if ((__builtin_expect(!!(!(flat_string->IsOneByteRepresentation
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19069, "Check failed: %s."
, "flat_string->IsOneByteRepresentation()"); } } while (0)
;
19070
19071 // Create external resource.
19072 uint16_t* uc16_buffer = new uint16_t[length + 1];
19073
19074 i::String::WriteToFlat(*flat_string, uc16_buffer, 0, length);
19075 uc16_buffer[length] = 0;
19076
19077 TestResource resource(uc16_buffer);
19078
19079 flat_string->MakeExternal(&resource);
19080
19081 CHECK(flat_string->IsTwoByteRepresentation())do { if ((__builtin_expect(!!(!(flat_string->IsTwoByteRepresentation
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19081, "Check failed: %s."
, "flat_string->IsTwoByteRepresentation()"); } } while (0)
;
19082
19083 // If the cons string has been short-circuited, skip the following checks.
19084 if (!string.is_identical_to(flat_string)) {
19085 // At this point, we should have a Cons string which is flat and one-byte,
19086 // with a first half that is a two-byte string (although it only contains
19087 // one-byte characters). This is a valid sequence of steps, and it can
19088 // happen in real pages.
19089 CHECK(string->IsOneByteRepresentation())do { if ((__builtin_expect(!!(!(string->IsOneByteRepresentation
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19089, "Check failed: %s."
, "string->IsOneByteRepresentation()"); } } while (0)
;
19090 i::ConsString* cons = i::ConsString::cast(*string);
19091 CHECK_EQ(0, cons->second()->length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (cons
->second()->length()), "0" " " "==" " " "cons->second()->length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19091, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19092 CHECK(cons->first()->IsTwoByteRepresentation())do { if ((__builtin_expect(!!(!(cons->first()->IsTwoByteRepresentation
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19092, "Check failed: %s."
, "cons->first()->IsTwoByteRepresentation()"); } } while
(0)
;
19093 }
19094
19095 // Check that some string operations work.
19096
19097 // Atom RegExp.
19098 Local<Value> reresult = CompileRun("str2.match(/abel/g).length;");
19099 CHECK_EQ(6, reresult->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (reresult
->Int32Value(context.local()).FromJust()), "6" " " "==" " "
"reresult->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 19099, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19100
19101 // Nonatom RegExp.
19102 reresult = CompileRun("str2.match(/abe./g).length;");
19103 CHECK_EQ(6, reresult->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (reresult
->Int32Value(context.local()).FromJust()), "6" " " "==" " "
"reresult->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 19103, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19104
19105 reresult = CompileRun("str2.search(/bel/g);");
19106 CHECK_EQ(1, reresult->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (reresult
->Int32Value(context.local()).FromJust()), "1" " " "==" " "
"reresult->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 19106, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19107
19108 reresult = CompileRun("str2.search(/be./g);");
19109 CHECK_EQ(1, reresult->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (reresult
->Int32Value(context.local()).FromJust()), "1" " " "==" " "
"reresult->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 19109, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19110
19111 ExpectTrue("/bel/g.test(str2);");
19112
19113 ExpectTrue("/be./g.test(str2);");
19114
19115 reresult = CompileRun("/bel/g.exec(str2);");
19116 CHECK(!reresult->IsNull())do { if ((__builtin_expect(!!(!(!reresult->IsNull())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 19116, "Check failed: %s."
, "!reresult->IsNull()"); } } while (0)
;
19117
19118 reresult = CompileRun("/be./g.exec(str2);");
19119 CHECK(!reresult->IsNull())do { if ((__builtin_expect(!!(!(!reresult->IsNull())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 19119, "Check failed: %s."
, "!reresult->IsNull()"); } } while (0)
;
19120
19121 ExpectString("str2.substring(2, 10);", "elspenda");
19122
19123 ExpectString("str2.substring(2, 20);", "elspendabelabelspe");
19124
19125 ExpectString("str2.charAt(2);", "e");
19126
19127 ExpectObject("str2.indexOf('els');", indexof);
19128
19129 ExpectObject("str2.lastIndexOf('dab');", lastindexof);
19130
19131 reresult = CompileRun("str2.charCodeAt(2);");
19132 CHECK_EQ(static_cast<int32_t>('e'),do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int32_t>('e')), (reresult->Int32Value(context.local
()).FromJust()), "static_cast<int32_t>('e')" " " "==" " "
"reresult->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 19133, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
19133 reresult->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (static_cast
<int32_t>('e')), (reresult->Int32Value(context.local
()).FromJust()), "static_cast<int32_t>('e')" " " "==" " "
"reresult->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 19133, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19134}
19135
19136
19137TEST(ContainsOnlyOneByte)static void TestContainsOnlyOneByte(); CcTest register_test_ContainsOnlyOneByte
(TestContainsOnlyOneByte, "../test/cctest/test-api.cc", "ContainsOnlyOneByte"
, __null, true, true); static void TestContainsOnlyOneByte()
{
19138 v8::V8::Initialize();
19139 v8::Isolate* isolate = CcTest::isolate();
19140 v8::HandleScope scope(isolate);
19141 // Make a buffer long enough that it won't automatically be converted.
19142 const int length = 512;
19143 // Ensure word aligned assignment.
19144 const int aligned_length = length*sizeof(uintptr_t)/sizeof(uint16_t);
19145 v8::base::SmartArrayPointer<uintptr_t> aligned_contents(
19146 new uintptr_t[aligned_length]);
19147 uint16_t* string_contents =
19148 reinterpret_cast<uint16_t*>(aligned_contents.get());
19149 // Set to contain only one byte.
19150 for (int i = 0; i < length-1; i++) {
19151 string_contents[i] = 0x41;
19152 }
19153 string_contents[length-1] = 0;
19154 // Simple case.
19155 Local<String> string =
19156 String::NewExternalTwoByte(isolate,
19157 new TestResource(string_contents, NULL__null, false))
19158 .ToLocalChecked();
19159 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte())do { if ((__builtin_expect(!!(!(!string->IsOneByte() &&
string->ContainsOnlyOneByte())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19159, "Check failed: %s.", "!string->IsOneByte() && string->ContainsOnlyOneByte()"
); } } while (0)
;
19160 // Counter example.
19161 string = String::NewFromTwoByte(isolate, string_contents,
19162 v8::NewStringType::kNormal)
19163 .ToLocalChecked();
19164 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte())do { if ((__builtin_expect(!!(!(string->IsOneByte() &&
string->ContainsOnlyOneByte())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19164, "Check failed: %s.", "string->IsOneByte() && string->ContainsOnlyOneByte()"
); } } while (0)
;
19165 // Test left right and balanced cons strings.
19166 Local<String> base = v8_str("a");
19167 Local<String> left = base;
19168 Local<String> right = base;
19169 for (int i = 0; i < 1000; i++) {
19170 left = String::Concat(base, left);
19171 right = String::Concat(right, base);
19172 }
19173 Local<String> balanced = String::Concat(left, base);
19174 balanced = String::Concat(balanced, right);
19175 Local<String> cons_strings[] = {left, balanced, right};
19176 Local<String> two_byte =
19177 String::NewExternalTwoByte(isolate,
19178 new TestResource(string_contents, NULL__null, false))
19179 .ToLocalChecked();
19180 USE(two_byte); USE(cons_strings);
19181 for (size_t i = 0; i < arraysize(cons_strings)(sizeof(ArraySizeHelper(cons_strings))); i++) {
19182 // Base assumptions.
19183 string = cons_strings[i];
19184 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte())do { if ((__builtin_expect(!!(!(string->IsOneByte() &&
string->ContainsOnlyOneByte())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19184, "Check failed: %s.", "string->IsOneByte() && string->ContainsOnlyOneByte()"
); } } while (0)
;
19185 // Test left and right concatentation.
19186 string = String::Concat(two_byte, cons_strings[i]);
19187 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte())do { if ((__builtin_expect(!!(!(!string->IsOneByte() &&
string->ContainsOnlyOneByte())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19187, "Check failed: %s.", "!string->IsOneByte() && string->ContainsOnlyOneByte()"
); } } while (0)
;
19188 string = String::Concat(cons_strings[i], two_byte);
19189 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte())do { if ((__builtin_expect(!!(!(!string->IsOneByte() &&
string->ContainsOnlyOneByte())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19189, "Check failed: %s.", "!string->IsOneByte() && string->ContainsOnlyOneByte()"
); } } while (0)
;
19190 }
19191 // Set bits in different positions
19192 // for strings of different lengths and alignments.
19193 for (int alignment = 0; alignment < 7; alignment++) {
19194 for (int size = 2; alignment + size < length; size *= 2) {
19195 int zero_offset = size + alignment;
19196 string_contents[zero_offset] = 0;
19197 for (int i = 0; i < size; i++) {
19198 int shift = 8 + (i % 7);
19199 string_contents[alignment + i] = 1 << shift;
19200 string = String::NewExternalTwoByte(
19201 isolate,
19202 new TestResource(string_contents + alignment, NULL__null, false))
19203 .ToLocalChecked();
19204 CHECK_EQ(size, string->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (size),
(string->Length()), "size" " " "==" " " "string->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19204, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19205 CHECK(!string->ContainsOnlyOneByte())do { if ((__builtin_expect(!!(!(!string->ContainsOnlyOneByte
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19205, "Check failed: %s."
, "!string->ContainsOnlyOneByte()"); } } while (0)
;
19206 string_contents[alignment + i] = 0x41;
19207 }
19208 string_contents[zero_offset] = 0x41;
19209 }
19210 }
19211}
19212
19213
19214// Failed access check callback that performs a GC on each invocation.
19215void FailedAccessCheckCallbackGC(Local<v8::Object> target,
19216 v8::AccessType type,
19217 Local<v8::Value> data) {
19218 CcTest::heap()->CollectAllGarbage();
19219 CcTest::isolate()->ThrowException(
19220 v8::Exception::Error(v8_str("cross context")));
19221}
19222
19223
19224TEST(GCInFailedAccessCheckCallback)static void TestGCInFailedAccessCheckCallback(); CcTest register_test_GCInFailedAccessCheckCallback
(TestGCInFailedAccessCheckCallback, "../test/cctest/test-api.cc"
, "GCInFailedAccessCheckCallback", __null, true, true); static
void TestGCInFailedAccessCheckCallback()
{
19225 // Install a failed access check callback that performs a GC on each
19226 // invocation. Then force the callback to be called from va
19227
19228 v8::V8::Initialize();
19229 v8::Isolate* isolate = CcTest::isolate();
19230
19231 isolate->SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC);
19232
19233 v8::HandleScope scope(isolate);
19234
19235 // Create an ObjectTemplate for global objects and install access
19236 // check callbacks that will block access.
19237 v8::Local<v8::ObjectTemplate> global_template =
19238 v8::ObjectTemplate::New(isolate);
19239 global_template->SetAccessCheckCallback(AccessAlwaysBlocked);
19240
19241 // Create a context and set an x property on it's global object.
19242 LocalContext context0(NULL__null, global_template);
19243 CHECK(context0->Global()do { if ((__builtin_expect(!!(!(context0->Global() ->Set
(context0.local(), v8_str("x"), v8_num(42)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 19245, "Check failed: %s."
, "context0->Global() ->Set(context0.local(), v8_str(\"x\"), v8_num(42)) .FromJust()"
); } } while (0)
19244 ->Set(context0.local(), v8_str("x"), v8_num(42))do { if ((__builtin_expect(!!(!(context0->Global() ->Set
(context0.local(), v8_str("x"), v8_num(42)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 19245, "Check failed: %s."
, "context0->Global() ->Set(context0.local(), v8_str(\"x\"), v8_num(42)) .FromJust()"
); } } while (0)
19245 .FromJust())do { if ((__builtin_expect(!!(!(context0->Global() ->Set
(context0.local(), v8_str("x"), v8_num(42)) .FromJust())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 19245, "Check failed: %s."
, "context0->Global() ->Set(context0.local(), v8_str(\"x\"), v8_num(42)) .FromJust()"
); } } while (0)
;
19246 v8::Local<v8::Object> global0 = context0->Global();
19247
19248 // Create a context with a different security token so that the
19249 // failed access check callback will be called on each access.
19250 LocalContext context1(NULL__null, global_template);
19251 CHECK(context1->Global()do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 19253, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
19252 ->Set(context1.local(), v8_str("other"), global0)do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 19253, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
19253 .FromJust())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 19253, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
;
19254
19255 v8::TryCatch try_catch(isolate);
19256
19257 // Get property with failed access check.
19258 CHECK(CompileRun("other.x").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other.x").IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19258, "Check failed: %s."
, "CompileRun(\"other.x\").IsEmpty()"); } } while (0)
;
19259 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19259, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19260 try_catch.Reset();
19261
19262 // Get element with failed access check.
19263 CHECK(CompileRun("other[0]").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other[0]").IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19263, "Check failed: %s."
, "CompileRun(\"other[0]\").IsEmpty()"); } } while (0)
;
19264 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19264, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19265 try_catch.Reset();
19266
19267 // Set property with failed access check.
19268 CHECK(CompileRun("other.x = new Object()").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other.x = new Object()"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19268
, "Check failed: %s.", "CompileRun(\"other.x = new Object()\").IsEmpty()"
); } } while (0)
;
19269 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19269, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19270 try_catch.Reset();
19271
19272 // Set element with failed access check.
19273 CHECK(CompileRun("other[0] = new Object()").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("other[0] = new Object()"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19273
, "Check failed: %s.", "CompileRun(\"other[0] = new Object()\").IsEmpty()"
); } } while (0)
;
19274 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19274, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19275 try_catch.Reset();
19276
19277 // Get property attribute with failed access check.
19278 CHECK(CompileRun("\'x\' in other").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("\'x\' in other").
IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19278
, "Check failed: %s.", "CompileRun(\"\\'x\\' in other\").IsEmpty()"
); } } while (0)
;
19279 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19279, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19280 try_catch.Reset();
19281
19282 // Get property attribute for element with failed access check.
19283 CHECK(CompileRun("0 in other").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("0 in other").IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19283, "Check failed: %s."
, "CompileRun(\"0 in other\").IsEmpty()"); } } while (0)
;
19284 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19284, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19285 try_catch.Reset();
19286
19287 // Delete property.
19288 CHECK(CompileRun("delete other.x").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("delete other.x").
IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19288
, "Check failed: %s.", "CompileRun(\"delete other.x\").IsEmpty()"
); } } while (0)
;
19289 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19289, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19290 try_catch.Reset();
19291
19292 // Delete element.
19293 CHECK(global0->Delete(context1.local(), 0).IsNothing())do { if ((__builtin_expect(!!(!(global0->Delete(context1.local
(), 0).IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19293, "Check failed: %s.", "global0->Delete(context1.local(), 0).IsNothing()"
); } } while (0)
;
19294 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19294, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19295 try_catch.Reset();
19296
19297 // DefineAccessor.
19298 CHECK(global0->SetAccessor(context1.local(), v8_str("x"), GetXValue, NULL,do { if ((__builtin_expect(!!(!(global0->SetAccessor(context1
.local(), v8_str("x"), GetXValue, __null, v8_str("x")) .IsNothing
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19300, "Check failed: %s."
, "global0->SetAccessor(context1.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"x\")) .IsNothing()"
); } } while (0)
19299 v8_str("x"))do { if ((__builtin_expect(!!(!(global0->SetAccessor(context1
.local(), v8_str("x"), GetXValue, __null, v8_str("x")) .IsNothing
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19300, "Check failed: %s."
, "global0->SetAccessor(context1.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"x\")) .IsNothing()"
); } } while (0)
19300 .IsNothing())do { if ((__builtin_expect(!!(!(global0->SetAccessor(context1
.local(), v8_str("x"), GetXValue, __null, v8_str("x")) .IsNothing
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19300, "Check failed: %s."
, "global0->SetAccessor(context1.local(), v8_str(\"x\"), GetXValue, NULL, v8_str(\"x\")) .IsNothing()"
); } } while (0)
;
19301 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19301, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19302 try_catch.Reset();
19303
19304 // Define JavaScript accessor.
19305 CHECK(CompileRun(do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.__defineGetter__.call("
" other, \'x\', function() { return 42; })").IsEmpty())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 19307, "Check failed: %s."
, "CompileRun( \"Object.prototype.__defineGetter__.call(\" \" other, \\'x\\', function() { return 42; })\").IsEmpty()"
); } } while (0)
19306 "Object.prototype.__defineGetter__.call("do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.__defineGetter__.call("
" other, \'x\', function() { return 42; })").IsEmpty())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 19307, "Check failed: %s."
, "CompileRun( \"Object.prototype.__defineGetter__.call(\" \" other, \\'x\\', function() { return 42; })\").IsEmpty()"
); } } while (0)
19307 " other, \'x\', function() { return 42; })").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.__defineGetter__.call("
" other, \'x\', function() { return 42; })").IsEmpty())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 19307, "Check failed: %s."
, "CompileRun( \"Object.prototype.__defineGetter__.call(\" \" other, \\'x\\', function() { return 42; })\").IsEmpty()"
); } } while (0)
;
19308 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19308, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19309 try_catch.Reset();
19310
19311 // LookupAccessor.
19312 CHECK(CompileRun(do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.__lookupGetter__.call("
" other, \'x\')").IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19314, "Check failed: %s.", "CompileRun( \"Object.prototype.__lookupGetter__.call(\" \" other, \\'x\\')\").IsEmpty()"
); } } while (0)
19313 "Object.prototype.__lookupGetter__.call("do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.__lookupGetter__.call("
" other, \'x\')").IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19314, "Check failed: %s.", "CompileRun( \"Object.prototype.__lookupGetter__.call(\" \" other, \\'x\\')\").IsEmpty()"
); } } while (0)
19314 " other, \'x\')").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.__lookupGetter__.call("
" other, \'x\')").IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19314, "Check failed: %s.", "CompileRun( \"Object.prototype.__lookupGetter__.call(\" \" other, \\'x\\')\").IsEmpty()"
); } } while (0)
;
19315 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19315, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19316 try_catch.Reset();
19317
19318 // HasOwnElement.
19319 CHECK(CompileRun(do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.hasOwnProperty.call("
"other, \'0\')").IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19321, "Check failed: %s.", "CompileRun( \"Object.prototype.hasOwnProperty.call(\" \"other, \\'0\\')\").IsEmpty()"
); } } while (0)
19320 "Object.prototype.hasOwnProperty.call("do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.hasOwnProperty.call("
"other, \'0\')").IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19321, "Check failed: %s.", "CompileRun( \"Object.prototype.hasOwnProperty.call(\" \"other, \\'0\\')\").IsEmpty()"
); } } while (0)
19321 "other, \'0\')").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun( "Object.prototype.hasOwnProperty.call("
"other, \'0\')").IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19321, "Check failed: %s.", "CompileRun( \"Object.prototype.hasOwnProperty.call(\" \"other, \\'0\\')\").IsEmpty()"
); } } while (0)
;
19322 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19322, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19323 try_catch.Reset();
19324
19325 CHECK(global0->HasRealIndexedProperty(context1.local(), 0).IsNothing())do { if ((__builtin_expect(!!(!(global0->HasRealIndexedProperty
(context1.local(), 0).IsNothing())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 19325, "Check failed: %s.", "global0->HasRealIndexedProperty(context1.local(), 0).IsNothing()"
); } } while (0)
;
19326 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19326, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19327 try_catch.Reset();
19328
19329 CHECK(do { if ((__builtin_expect(!!(!(global0->HasRealNamedProperty
(context1.local(), v8_str("x")).IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19330, "Check failed: %s.", "global0->HasRealNamedProperty(context1.local(), v8_str(\"x\")).IsNothing()"
); } } while (0)
19330 global0->HasRealNamedProperty(context1.local(), v8_str("x")).IsNothing())do { if ((__builtin_expect(!!(!(global0->HasRealNamedProperty
(context1.local(), v8_str("x")).IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19330, "Check failed: %s.", "global0->HasRealNamedProperty(context1.local(), v8_str(\"x\")).IsNothing()"
); } } while (0)
;
19331 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19331, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19332 try_catch.Reset();
19333
19334 CHECK(global0->HasRealNamedCallbackProperty(context1.local(), v8_str("x"))do { if ((__builtin_expect(!!(!(global0->HasRealNamedCallbackProperty
(context1.local(), v8_str("x")) .IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19335, "Check failed: %s.", "global0->HasRealNamedCallbackProperty(context1.local(), v8_str(\"x\")) .IsNothing()"
); } } while (0)
19335 .IsNothing())do { if ((__builtin_expect(!!(!(global0->HasRealNamedCallbackProperty
(context1.local(), v8_str("x")) .IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19335, "Check failed: %s.", "global0->HasRealNamedCallbackProperty(context1.local(), v8_str(\"x\")) .IsNothing()"
); } } while (0)
;
19336 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19336, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
19337 try_catch.Reset();
19338
19339 // Reset the failed access check callback so it does not influence
19340 // the other tests.
19341 isolate->SetFailedAccessCheckCallbackFunction(NULL__null);
19342}
19343
19344
19345TEST(IsolateNewDispose)static void TestIsolateNewDispose(); CcTest register_test_IsolateNewDispose
(TestIsolateNewDispose, "../test/cctest/test-api.cc", "IsolateNewDispose"
, __null, true, true); static void TestIsolateNewDispose()
{
19346 v8::Isolate* current_isolate = CcTest::isolate();
19347 v8::Isolate::CreateParams create_params;
19348 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
19349 v8::Isolate* isolate = v8::Isolate::New(create_params);
19350 CHECK(isolate != NULL)do { if ((__builtin_expect(!!(!(isolate != __null)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19350, "Check failed: %s.", "isolate != NULL"
); } } while (0)
;
19351 CHECK(current_isolate != isolate)do { if ((__builtin_expect(!!(!(current_isolate != isolate)),
0))) { V8_Fatal("../test/cctest/test-api.cc", 19351, "Check failed: %s."
, "current_isolate != isolate"); } } while (0)
;
19352 CHECK(current_isolate == CcTest::isolate())do { if ((__builtin_expect(!!(!(current_isolate == CcTest::isolate
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19352, "Check failed: %s."
, "current_isolate == CcTest::isolate()"); } } while (0)
;
19353
19354 isolate->SetFatalErrorHandler(StoringErrorCallback);
19355 last_location = last_message = NULL__null;
19356 isolate->Dispose();
19357 CHECK(!last_location)do { if ((__builtin_expect(!!(!(!last_location)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19357, "Check failed: %s.", "!last_location"
); } } while (0)
;
19358 CHECK(!last_message)do { if ((__builtin_expect(!!(!(!last_message)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19358, "Check failed: %s.", "!last_message"
); } } while (0)
;
19359}
19360
19361
19362UNINITIALIZED_TEST(DisposeIsolateWhenInUse)static void TestDisposeIsolateWhenInUse(); CcTest register_test_DisposeIsolateWhenInUse
(TestDisposeIsolateWhenInUse, "../test/cctest/test-api.cc", "DisposeIsolateWhenInUse"
, __null, true, false); static void TestDisposeIsolateWhenInUse
()
{
19363 v8::Isolate::CreateParams create_params;
19364 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
19365 v8::Isolate* isolate = v8::Isolate::New(create_params);
19366 {
19367 v8::Isolate::Scope i_scope(isolate);
19368 v8::HandleScope scope(isolate);
19369 LocalContext context(isolate);
19370 // Run something in this isolate.
19371 ExpectTrue("true");
19372 isolate->SetFatalErrorHandler(StoringErrorCallback);
19373 last_location = last_message = NULL__null;
19374 // Still entered, should fail.
19375 isolate->Dispose();
19376 CHECK(last_location)do { if ((__builtin_expect(!!(!(last_location)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19376, "Check failed: %s.", "last_location"
); } } while (0)
;
19377 CHECK(last_message)do { if ((__builtin_expect(!!(!(last_message)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19377, "Check failed: %s.", "last_message"
); } } while (0)
;
19378 }
19379 isolate->Dispose();
19380}
19381
19382
19383static void BreakArrayGuarantees(const char* script) {
19384 v8::Isolate::CreateParams create_params;
19385 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
19386 v8::Isolate* isolate1 = v8::Isolate::New(create_params);
19387 isolate1->Enter();
19388 v8::Persistent<v8::Context> context1;
19389 {
19390 v8::HandleScope scope(isolate1);
19391 context1.Reset(isolate1, Context::New(isolate1));
19392 }
19393
19394 {
19395 v8::HandleScope scope(isolate1);
19396 v8::Local<v8::Context> context =
19397 v8::Local<v8::Context>::New(isolate1, context1);
19398 v8::Context::Scope context_scope(context);
19399 v8::internal::Isolate* i_isolate =
19400 reinterpret_cast<v8::internal::Isolate*>(isolate1);
19401 CHECK_EQ(true, i_isolate->IsFastArrayConstructorPrototypeChainIntact())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (true),
(i_isolate->IsFastArrayConstructorPrototypeChainIntact())
, "true" " " "==" " " "i_isolate->IsFastArrayConstructorPrototypeChainIntact()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19401, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19402 // Run something in new isolate.
19403 CompileRun(script);
19404 CHECK_EQ(false, i_isolate->IsFastArrayConstructorPrototypeChainIntact())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (i_isolate->IsFastArrayConstructorPrototypeChainIntact()
), "false" " " "==" " " "i_isolate->IsFastArrayConstructorPrototypeChainIntact()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19404, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19405 }
19406 isolate1->Exit();
19407 isolate1->Dispose();
19408}
19409
19410
19411TEST(VerifyArrayPrototypeGuarantees)static void TestVerifyArrayPrototypeGuarantees(); CcTest register_test_VerifyArrayPrototypeGuarantees
(TestVerifyArrayPrototypeGuarantees, "../test/cctest/test-api.cc"
, "VerifyArrayPrototypeGuarantees", __null, true, true); static
void TestVerifyArrayPrototypeGuarantees()
{
19412 // Break fast array hole handling by element changes.
19413 BreakArrayGuarantees("[].__proto__[1] = 3;");
19414 BreakArrayGuarantees("Object.prototype[3] = 'three';");
19415 BreakArrayGuarantees("Array.prototype.push(1);");
19416 BreakArrayGuarantees("Array.prototype.unshift(1);");
19417 // Break fast array hole handling by changing length.
19418 BreakArrayGuarantees("Array.prototype.length = 30;");
19419 // Break fast array hole handling by prototype structure changes.
19420 BreakArrayGuarantees("[].__proto__.__proto__ = { funny: true };");
19421 // By sending elements to dictionary mode.
19422 BreakArrayGuarantees(
19423 "Object.defineProperty(Array.prototype, 0, {"
19424 " get: function() { return 3; }});");
19425 BreakArrayGuarantees(
19426 "Object.defineProperty(Object.prototype, 0, {"
19427 " get: function() { return 3; }});");
19428}
19429
19430
19431TEST(RunTwoIsolatesOnSingleThread)static void TestRunTwoIsolatesOnSingleThread(); CcTest register_test_RunTwoIsolatesOnSingleThread
(TestRunTwoIsolatesOnSingleThread, "../test/cctest/test-api.cc"
, "RunTwoIsolatesOnSingleThread", __null, true, true); static
void TestRunTwoIsolatesOnSingleThread()
{
19432 // Run isolate 1.
19433 v8::Isolate::CreateParams create_params;
19434 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
19435 v8::Isolate* isolate1 = v8::Isolate::New(create_params);
19436 isolate1->Enter();
19437 v8::Persistent<v8::Context> context1;
19438 {
19439 v8::HandleScope scope(isolate1);
19440 context1.Reset(isolate1, Context::New(isolate1));
19441 }
19442
19443 {
19444 v8::HandleScope scope(isolate1);
19445 v8::Local<v8::Context> context =
19446 v8::Local<v8::Context>::New(isolate1, context1);
19447 v8::Context::Scope context_scope(context);
19448 // Run something in new isolate.
19449 CompileRun("var foo = 'isolate 1';");
19450 ExpectString("function f() { return foo; }; f()", "isolate 1");
19451 }
19452
19453 // Run isolate 2.
19454 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
19455 v8::Persistent<v8::Context> context2;
19456
19457 {
19458 v8::Isolate::Scope iscope(isolate2);
19459 v8::HandleScope scope(isolate2);
19460 context2.Reset(isolate2, Context::New(isolate2));
19461 v8::Local<v8::Context> context =
19462 v8::Local<v8::Context>::New(isolate2, context2);
19463 v8::Context::Scope context_scope(context);
19464
19465 // Run something in new isolate.
19466 CompileRun("var foo = 'isolate 2';");
19467 ExpectString("function f() { return foo; }; f()", "isolate 2");
19468 }
19469
19470 {
19471 v8::HandleScope scope(isolate1);
19472 v8::Local<v8::Context> context =
19473 v8::Local<v8::Context>::New(isolate1, context1);
19474 v8::Context::Scope context_scope(context);
19475 // Now again in isolate 1
19476 ExpectString("function f() { return foo; }; f()", "isolate 1");
19477 }
19478
19479 isolate1->Exit();
19480
19481 // Run some stuff in default isolate.
19482 v8::Persistent<v8::Context> context_default;
19483 {
19484 v8::Isolate* isolate = CcTest::isolate();
19485 v8::Isolate::Scope iscope(isolate);
19486 v8::HandleScope scope(isolate);
19487 context_default.Reset(isolate, Context::New(isolate));
19488 }
19489
19490 {
19491 v8::HandleScope scope(CcTest::isolate());
19492 v8::Local<v8::Context> context =
19493 v8::Local<v8::Context>::New(CcTest::isolate(), context_default);
19494 v8::Context::Scope context_scope(context);
19495 // Variables in other isolates should be not available, verify there
19496 // is an exception.
19497 ExpectTrue("function f() {"
19498 " try {"
19499 " foo;"
19500 " return false;"
19501 " } catch(e) {"
19502 " return true;"
19503 " }"
19504 "};"
19505 "var isDefaultIsolate = true;"
19506 "f()");
19507 }
19508
19509 isolate1->Enter();
19510
19511 {
19512 v8::Isolate::Scope iscope(isolate2);
19513 v8::HandleScope scope(isolate2);
19514 v8::Local<v8::Context> context =
19515 v8::Local<v8::Context>::New(isolate2, context2);
19516 v8::Context::Scope context_scope(context);
19517 ExpectString("function f() { return foo; }; f()", "isolate 2");
19518 }
19519
19520 {
19521 v8::HandleScope scope(v8::Isolate::GetCurrent());
19522 v8::Local<v8::Context> context =
19523 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1);
19524 v8::Context::Scope context_scope(context);
19525 ExpectString("function f() { return foo; }; f()", "isolate 1");
19526 }
19527
19528 {
19529 v8::Isolate::Scope iscope(isolate2);
19530 context2.Reset();
19531 }
19532
19533 context1.Reset();
19534 isolate1->Exit();
19535
19536 isolate2->SetFatalErrorHandler(StoringErrorCallback);
19537 last_location = last_message = NULL__null;
19538
19539 isolate1->Dispose();
19540 CHECK(!last_location)do { if ((__builtin_expect(!!(!(!last_location)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19540, "Check failed: %s.", "!last_location"
); } } while (0)
;
19541 CHECK(!last_message)do { if ((__builtin_expect(!!(!(!last_message)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19541, "Check failed: %s.", "!last_message"
); } } while (0)
;
19542
19543 isolate2->Dispose();
19544 CHECK(!last_location)do { if ((__builtin_expect(!!(!(!last_location)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19544, "Check failed: %s.", "!last_location"
); } } while (0)
;
19545 CHECK(!last_message)do { if ((__builtin_expect(!!(!(!last_message)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19545, "Check failed: %s.", "!last_message"
); } } while (0)
;
19546
19547 // Check that default isolate still runs.
19548 {
19549 v8::HandleScope scope(CcTest::isolate());
19550 v8::Local<v8::Context> context =
19551 v8::Local<v8::Context>::New(CcTest::isolate(), context_default);
19552 v8::Context::Scope context_scope(context);
19553 ExpectTrue("function f() { return isDefaultIsolate; }; f()");
19554 }
19555}
19556
19557
19558static int CalcFibonacci(v8::Isolate* isolate, int limit) {
19559 v8::Isolate::Scope isolate_scope(isolate);
19560 v8::HandleScope scope(isolate);
19561 LocalContext context(isolate);
19562 i::ScopedVector<char> code(1024);
19563 i::SNPrintF(code, "function fib(n) {"
19564 " if (n <= 2) return 1;"
19565 " return fib(n-1) + fib(n-2);"
19566 "}"
19567 "fib(%d)", limit);
19568 Local<Value> value = CompileRun(code.start());
19569 CHECK(value->IsNumber())do { if ((__builtin_expect(!!(!(value->IsNumber())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 19569, "Check failed: %s."
, "value->IsNumber()"); } } while (0)
;
19570 return static_cast<int>(value->NumberValue(context.local()).FromJust());
19571}
19572
19573class IsolateThread : public v8::base::Thread {
19574 public:
19575 explicit IsolateThread(int fib_limit)
19576 : Thread(Options("IsolateThread")), fib_limit_(fib_limit), result_(0) {}
19577
19578 void Run() {
19579 v8::Isolate::CreateParams create_params;
19580 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
19581 v8::Isolate* isolate = v8::Isolate::New(create_params);
19582 result_ = CalcFibonacci(isolate, fib_limit_);
19583 isolate->Dispose();
19584 }
19585
19586 int result() { return result_; }
19587
19588 private:
19589 int fib_limit_;
19590 int result_;
19591};
19592
19593
19594TEST(MultipleIsolatesOnIndividualThreads)static void TestMultipleIsolatesOnIndividualThreads(); CcTest
register_test_MultipleIsolatesOnIndividualThreads(TestMultipleIsolatesOnIndividualThreads
, "../test/cctest/test-api.cc", "MultipleIsolatesOnIndividualThreads"
, __null, true, true); static void TestMultipleIsolatesOnIndividualThreads
()
{
19595 IsolateThread thread1(21);
19596 IsolateThread thread2(12);
19597
19598 // Compute some fibonacci numbers on 3 threads in 3 isolates.
19599 thread1.Start();
19600 thread2.Start();
19601
19602 int result1 = CalcFibonacci(CcTest::isolate(), 21);
19603 int result2 = CalcFibonacci(CcTest::isolate(), 12);
19604
19605 thread1.Join();
19606 thread2.Join();
19607
19608 // Compare results. The actual fibonacci numbers for 12 and 21 are taken
19609 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number
19610 CHECK_EQ(result1, 10946)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result1
), (10946), "result1" " " "==" " " "10946")) { V8_Fatal("../test/cctest/test-api.cc"
, 19610, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19611 CHECK_EQ(result2, 144)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result2
), (144), "result2" " " "==" " " "144")) { V8_Fatal("../test/cctest/test-api.cc"
, 19611, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19612 CHECK_EQ(result1, thread1.result())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result1
), (thread1.result()), "result1" " " "==" " " "thread1.result()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19612, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19613 CHECK_EQ(result2, thread2.result())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (result2
), (thread2.result()), "result2" " " "==" " " "thread2.result()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19613, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19614}
19615
19616
19617TEST(IsolateDifferentContexts)static void TestIsolateDifferentContexts(); CcTest register_test_IsolateDifferentContexts
(TestIsolateDifferentContexts, "../test/cctest/test-api.cc", "IsolateDifferentContexts"
, __null, true, true); static void TestIsolateDifferentContexts
()
{
19618 v8::Isolate::CreateParams create_params;
19619 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
19620 v8::Isolate* isolate = v8::Isolate::New(create_params);
19621 Local<v8::Context> context;
19622 {
19623 v8::Isolate::Scope isolate_scope(isolate);
19624 v8::HandleScope handle_scope(isolate);
19625 context = v8::Context::New(isolate);
19626 v8::Context::Scope context_scope(context);
19627 Local<Value> v = CompileRun("2");
19628 CHECK(v->IsNumber())do { if ((__builtin_expect(!!(!(v->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19628, "Check failed: %s.", "v->IsNumber()"
); } } while (0)
;
19629 CHECK_EQ(2, static_cast<int>(v->NumberValue(context).FromJust()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (static_cast
<int>(v->NumberValue(context).FromJust())), "2" " " "=="
" " "static_cast<int>(v->NumberValue(context).FromJust())"
)) { V8_Fatal("../test/cctest/test-api.cc", 19629, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19630 }
19631 {
19632 v8::Isolate::Scope isolate_scope(isolate);
19633 v8::HandleScope handle_scope(isolate);
19634 context = v8::Context::New(isolate);
19635 v8::Context::Scope context_scope(context);
19636 Local<Value> v = CompileRun("22");
19637 CHECK(v->IsNumber())do { if ((__builtin_expect(!!(!(v->IsNumber())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19637, "Check failed: %s.", "v->IsNumber()"
); } } while (0)
;
19638 CHECK_EQ(22, static_cast<int>(v->NumberValue(context).FromJust()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (22), (
static_cast<int>(v->NumberValue(context).FromJust())
), "22" " " "==" " " "static_cast<int>(v->NumberValue(context).FromJust())"
)) { V8_Fatal("../test/cctest/test-api.cc", 19638, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19639 }
19640 isolate->Dispose();
19641}
19642
19643class InitDefaultIsolateThread : public v8::base::Thread {
19644 public:
19645 enum TestCase {
19646 SetResourceConstraints,
19647 SetFatalHandler,
19648 SetCounterFunction,
19649 SetCreateHistogramFunction,
19650 SetAddHistogramSampleFunction
19651 };
19652
19653 explicit InitDefaultIsolateThread(TestCase testCase)
19654 : Thread(Options("InitDefaultIsolateThread")),
19655 testCase_(testCase),
19656 result_(false) {}
19657
19658 void Run() {
19659 v8::Isolate::CreateParams create_params;
19660 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
19661 const intptr_t pageSizeMult =
19662 v8::internal::Page::kPageSize / v8::internal::MB;
19663 switch (testCase_) {
19664 case SetResourceConstraints: {
19665 create_params.constraints.set_max_semi_space_size(1 * pageSizeMult);
19666 create_params.constraints.set_max_old_space_size(4 * pageSizeMult);
19667 break;
19668 }
19669 default:
19670 break;
19671 }
19672 v8::Isolate* isolate = v8::Isolate::New(create_params);
19673 isolate->Enter();
19674 switch (testCase_) {
19675 case SetResourceConstraints:
19676 // Already handled in pre-Isolate-creation block.
19677 break;
19678
19679 case SetFatalHandler:
19680 isolate->SetFatalErrorHandler(NULL__null);
19681 break;
19682
19683 case SetCounterFunction:
19684 CcTest::isolate()->SetCounterFunction(NULL__null);
19685 break;
19686
19687 case SetCreateHistogramFunction:
19688 CcTest::isolate()->SetCreateHistogramFunction(NULL__null);
19689 break;
19690
19691 case SetAddHistogramSampleFunction:
19692 CcTest::isolate()->SetAddHistogramSampleFunction(NULL__null);
19693 break;
19694 }
19695 isolate->Exit();
19696 isolate->Dispose();
19697 result_ = true;
19698 }
19699
19700 bool result() { return result_; }
19701
19702 private:
19703 TestCase testCase_;
19704 bool result_;
19705};
19706
19707
19708static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) {
19709 InitDefaultIsolateThread thread(testCase);
19710 thread.Start();
19711 thread.Join();
19712 CHECK_EQ(thread.result(), true)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (thread
.result()), (true), "thread.result()" " " "==" " " "true")) {
V8_Fatal("../test/cctest/test-api.cc", 19712, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19713}
19714
19715
19716TEST(InitializeDefaultIsolateOnSecondaryThread1)static void TestInitializeDefaultIsolateOnSecondaryThread1();
CcTest register_test_InitializeDefaultIsolateOnSecondaryThread1
(TestInitializeDefaultIsolateOnSecondaryThread1, "../test/cctest/test-api.cc"
, "InitializeDefaultIsolateOnSecondaryThread1", __null, true,
true); static void TestInitializeDefaultIsolateOnSecondaryThread1
()
{
19717 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints);
19718}
19719
19720
19721TEST(InitializeDefaultIsolateOnSecondaryThread2)static void TestInitializeDefaultIsolateOnSecondaryThread2();
CcTest register_test_InitializeDefaultIsolateOnSecondaryThread2
(TestInitializeDefaultIsolateOnSecondaryThread2, "../test/cctest/test-api.cc"
, "InitializeDefaultIsolateOnSecondaryThread2", __null, true,
true); static void TestInitializeDefaultIsolateOnSecondaryThread2
()
{
19722 InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler);
19723}
19724
19725
19726TEST(InitializeDefaultIsolateOnSecondaryThread3)static void TestInitializeDefaultIsolateOnSecondaryThread3();
CcTest register_test_InitializeDefaultIsolateOnSecondaryThread3
(TestInitializeDefaultIsolateOnSecondaryThread3, "../test/cctest/test-api.cc"
, "InitializeDefaultIsolateOnSecondaryThread3", __null, true,
true); static void TestInitializeDefaultIsolateOnSecondaryThread3
()
{
19727 InitializeTestHelper(InitDefaultIsolateThread::SetCounterFunction);
19728}
19729
19730
19731TEST(InitializeDefaultIsolateOnSecondaryThread4)static void TestInitializeDefaultIsolateOnSecondaryThread4();
CcTest register_test_InitializeDefaultIsolateOnSecondaryThread4
(TestInitializeDefaultIsolateOnSecondaryThread4, "../test/cctest/test-api.cc"
, "InitializeDefaultIsolateOnSecondaryThread4", __null, true,
true); static void TestInitializeDefaultIsolateOnSecondaryThread4
()
{
19732 InitializeTestHelper(InitDefaultIsolateThread::SetCreateHistogramFunction);
19733}
19734
19735
19736TEST(InitializeDefaultIsolateOnSecondaryThread5)static void TestInitializeDefaultIsolateOnSecondaryThread5();
CcTest register_test_InitializeDefaultIsolateOnSecondaryThread5
(TestInitializeDefaultIsolateOnSecondaryThread5, "../test/cctest/test-api.cc"
, "InitializeDefaultIsolateOnSecondaryThread5", __null, true,
true); static void TestInitializeDefaultIsolateOnSecondaryThread5
()
{
19737 InitializeTestHelper(InitDefaultIsolateThread::SetAddHistogramSampleFunction);
19738}
19739
19740
19741TEST(StringCheckMultipleContexts)static void TestStringCheckMultipleContexts(); CcTest register_test_StringCheckMultipleContexts
(TestStringCheckMultipleContexts, "../test/cctest/test-api.cc"
, "StringCheckMultipleContexts", __null, true, true); static void
TestStringCheckMultipleContexts()
{
19742 const char* code =
19743 "(function() { return \"a\".charAt(0); })()";
19744
19745 {
19746 // Run the code twice in the first context to initialize the call IC.
19747 LocalContext context1;
19748 v8::HandleScope scope(context1->GetIsolate());
19749 ExpectString(code, "a");
19750 ExpectString(code, "a");
19751 }
19752
19753 {
19754 // Change the String.prototype in the second context and check
19755 // that the right function gets called.
19756 LocalContext context2;
19757 v8::HandleScope scope(context2->GetIsolate());
19758 CompileRun("String.prototype.charAt = function() { return \"not a\"; }");
19759 ExpectString(code, "not a");
19760 }
19761}
19762
19763
19764TEST(NumberCheckMultipleContexts)static void TestNumberCheckMultipleContexts(); CcTest register_test_NumberCheckMultipleContexts
(TestNumberCheckMultipleContexts, "../test/cctest/test-api.cc"
, "NumberCheckMultipleContexts", __null, true, true); static void
TestNumberCheckMultipleContexts()
{
19765 const char* code =
19766 "(function() { return (42).toString(); })()";
19767
19768 {
19769 // Run the code twice in the first context to initialize the call IC.
19770 LocalContext context1;
19771 v8::HandleScope scope(context1->GetIsolate());
19772 ExpectString(code, "42");
19773 ExpectString(code, "42");
19774 }
19775
19776 {
19777 // Change the Number.prototype in the second context and check
19778 // that the right function gets called.
19779 LocalContext context2;
19780 v8::HandleScope scope(context2->GetIsolate());
19781 CompileRun("Number.prototype.toString = function() { return \"not 42\"; }");
19782 ExpectString(code, "not 42");
19783 }
19784}
19785
19786
19787TEST(BooleanCheckMultipleContexts)static void TestBooleanCheckMultipleContexts(); CcTest register_test_BooleanCheckMultipleContexts
(TestBooleanCheckMultipleContexts, "../test/cctest/test-api.cc"
, "BooleanCheckMultipleContexts", __null, true, true); static
void TestBooleanCheckMultipleContexts()
{
19788 const char* code =
19789 "(function() { return true.toString(); })()";
19790
19791 {
19792 // Run the code twice in the first context to initialize the call IC.
19793 LocalContext context1;
19794 v8::HandleScope scope(context1->GetIsolate());
19795 ExpectString(code, "true");
19796 ExpectString(code, "true");
19797 }
19798
19799 {
19800 // Change the Boolean.prototype in the second context and check
19801 // that the right function gets called.
19802 LocalContext context2;
19803 v8::HandleScope scope(context2->GetIsolate());
19804 CompileRun("Boolean.prototype.toString = function() { return \"\"; }");
19805 ExpectString(code, "");
19806 }
19807}
19808
19809
19810TEST(DontDeleteCellLoadIC)static void TestDontDeleteCellLoadIC(); CcTest register_test_DontDeleteCellLoadIC
(TestDontDeleteCellLoadIC, "../test/cctest/test-api.cc", "DontDeleteCellLoadIC"
, __null, true, true); static void TestDontDeleteCellLoadIC()
{
19811 const char* function_code =
19812 "function readCell() { while (true) { return cell; } }";
19813
19814 {
19815 // Run the code twice in the first context to initialize the load
19816 // IC for a don't delete cell.
19817 LocalContext context1;
19818 v8::HandleScope scope(context1->GetIsolate());
19819 CompileRun("var cell = \"first\";");
19820 ExpectBoolean("delete cell", false);
19821 CompileRun(function_code);
19822 ExpectString("readCell()", "first");
19823 ExpectString("readCell()", "first");
19824 }
19825
19826 {
19827 // Use a deletable cell in the second context.
19828 LocalContext context2;
19829 v8::HandleScope scope(context2->GetIsolate());
19830 CompileRun("cell = \"second\";");
19831 CompileRun(function_code);
19832 ExpectString("readCell()", "second");
19833 ExpectBoolean("delete cell", true);
19834 ExpectString("(function() {"
19835 " try {"
19836 " return readCell();"
19837 " } catch(e) {"
19838 " return e.toString();"
19839 " }"
19840 "})()",
19841 "ReferenceError: cell is not defined");
19842 CompileRun("cell = \"new_second\";");
19843 CcTest::heap()->CollectAllGarbage();
19844 ExpectString("readCell()", "new_second");
19845 ExpectString("readCell()", "new_second");
19846 }
19847}
19848
19849
19850class Visitor42 : public v8::PersistentHandleVisitor {
19851 public:
19852 explicit Visitor42(v8::Persistent<v8::Object>* object)
19853 : counter_(0), object_(object) { }
19854
19855 virtual void VisitPersistentHandle(Persistent<Value>* value,
19856 uint16_t class_id) {
19857 if (class_id != 42) return;
19858 CHECK_EQ(42, value->WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->WrapperClassId()), "42" " " "==" " " "value->WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19858, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19859 v8::Isolate* isolate = CcTest::isolate();
19860 v8::HandleScope handle_scope(isolate);
19861 v8::Local<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value);
19862 v8::Local<v8::Value> object = v8::Local<v8::Object>::New(isolate, *object_);
19863 CHECK(handle->IsObject())do { if ((__builtin_expect(!!(!(handle->IsObject())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 19863, "Check failed: %s."
, "handle->IsObject()"); } } while (0)
;
19864 CHECK(Local<Object>::Cast(handle)do { if ((__builtin_expect(!!(!(Local<Object>::Cast(handle
) ->Equals(isolate->GetCurrentContext(), object) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19866, "Check failed: %s."
, "Local<Object>::Cast(handle) ->Equals(isolate->GetCurrentContext(), object) .FromJust()"
); } } while (0)
19865 ->Equals(isolate->GetCurrentContext(), object)do { if ((__builtin_expect(!!(!(Local<Object>::Cast(handle
) ->Equals(isolate->GetCurrentContext(), object) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19866, "Check failed: %s."
, "Local<Object>::Cast(handle) ->Equals(isolate->GetCurrentContext(), object) .FromJust()"
); } } while (0)
19866 .FromJust())do { if ((__builtin_expect(!!(!(Local<Object>::Cast(handle
) ->Equals(isolate->GetCurrentContext(), object) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 19866, "Check failed: %s."
, "Local<Object>::Cast(handle) ->Equals(isolate->GetCurrentContext(), object) .FromJust()"
); } } while (0)
;
19867 ++counter_;
19868 }
19869
19870 int counter_;
19871 v8::Persistent<v8::Object>* object_;
19872};
19873
19874
19875TEST(PersistentHandleVisitor)static void TestPersistentHandleVisitor(); CcTest register_test_PersistentHandleVisitor
(TestPersistentHandleVisitor, "../test/cctest/test-api.cc", "PersistentHandleVisitor"
, __null, true, true); static void TestPersistentHandleVisitor
()
{
19876 LocalContext context;
19877 v8::Isolate* isolate = context->GetIsolate();
19878 v8::HandleScope scope(isolate);
19879 v8::Persistent<v8::Object> object(isolate, v8::Object::New(isolate));
19880 CHECK_EQ(0, object.WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (object
.WrapperClassId()), "0" " " "==" " " "object.WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19880, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19881 object.SetWrapperClassId(42);
19882 CHECK_EQ(42, object.WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
object.WrapperClassId()), "42" " " "==" " " "object.WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19882, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19883
19884 Visitor42 visitor(&object);
19885 isolate->VisitHandlesWithClassIds(&visitor);
19886 CHECK_EQ(1, visitor.counter_)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (visitor
.counter_), "1" " " "==" " " "visitor.counter_")) { V8_Fatal(
"../test/cctest/test-api.cc", 19886, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19887
19888 object.Reset();
19889}
19890
19891
19892TEST(WrapperClassId)static void TestWrapperClassId(); CcTest register_test_WrapperClassId
(TestWrapperClassId, "../test/cctest/test-api.cc", "WrapperClassId"
, __null, true, true); static void TestWrapperClassId()
{
19893 LocalContext context;
19894 v8::Isolate* isolate = context->GetIsolate();
19895 v8::HandleScope scope(isolate);
19896 v8::Persistent<v8::Object> object(isolate, v8::Object::New(isolate));
19897 CHECK_EQ(0, object.WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (object
.WrapperClassId()), "0" " " "==" " " "object.WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19897, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19898 object.SetWrapperClassId(65535);
19899 CHECK_EQ(65535, object.WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (65535)
, (object.WrapperClassId()), "65535" " " "==" " " "object.WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19899, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19900 object.Reset();
19901}
19902
19903
19904TEST(PersistentHandleInNewSpaceVisitor)static void TestPersistentHandleInNewSpaceVisitor(); CcTest register_test_PersistentHandleInNewSpaceVisitor
(TestPersistentHandleInNewSpaceVisitor, "../test/cctest/test-api.cc"
, "PersistentHandleInNewSpaceVisitor", __null, true, true); static
void TestPersistentHandleInNewSpaceVisitor()
{
19905 LocalContext context;
19906 v8::Isolate* isolate = context->GetIsolate();
19907 v8::HandleScope scope(isolate);
19908 v8::Persistent<v8::Object> object1(isolate, v8::Object::New(isolate));
19909 CHECK_EQ(0, object1.WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (object1
.WrapperClassId()), "0" " " "==" " " "object1.WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19909, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19910 object1.SetWrapperClassId(42);
19911 CHECK_EQ(42, object1.WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
object1.WrapperClassId()), "42" " " "==" " " "object1.WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19911, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19912
19913 CcTest::heap()->CollectAllGarbage();
19914 CcTest::heap()->CollectAllGarbage();
19915
19916 v8::Persistent<v8::Object> object2(isolate, v8::Object::New(isolate));
19917 CHECK_EQ(0, object2.WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (object2
.WrapperClassId()), "0" " " "==" " " "object2.WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19917, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19918 object2.SetWrapperClassId(42);
19919 CHECK_EQ(42, object2.WrapperClassId())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
object2.WrapperClassId()), "42" " " "==" " " "object2.WrapperClassId()"
)) { V8_Fatal("../test/cctest/test-api.cc", 19919, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19920
19921 Visitor42 visitor(&object2);
19922 isolate->VisitHandlesForPartialDependence(&visitor);
19923 CHECK_EQ(1, visitor.counter_)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (visitor
.counter_), "1" " " "==" " " "visitor.counter_")) { V8_Fatal(
"../test/cctest/test-api.cc", 19923, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
19924
19925 object1.Reset();
19926 object2.Reset();
19927}
19928
19929
19930TEST(RegExp)static void TestRegExp(); CcTest register_test_RegExp(TestRegExp
, "../test/cctest/test-api.cc", "RegExp", __null, true, true)
; static void TestRegExp()
{
19931 i::FLAG_harmony_regexps = true;
19932 i::FLAG_harmony_unicode_regexps = true;
19933 LocalContext context;
19934 v8::HandleScope scope(context->GetIsolate());
19935
19936 v8::Local<v8::RegExp> re =
19937 v8::RegExp::New(context.local(), v8_str("foo"), v8::RegExp::kNone)
19938 .ToLocalChecked();
19939 CHECK(re->IsRegExp())do { if ((__builtin_expect(!!(!(re->IsRegExp())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19939, "Check failed: %s.", "re->IsRegExp()"
); } } while (0)
;
19940 CHECK(re->GetSource()->Equals(context.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("foo")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19940, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
19941 CHECK_EQ(v8::RegExp::kNone, re->GetFlags())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kNone), (re->GetFlags()), "v8::RegExp::kNone" " " "==" " "
"re->GetFlags()")) { V8_Fatal("../test/cctest/test-api.cc"
, 19941, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19942
19943 re = v8::RegExp::New(context.local(), v8_str("bar"),
19944 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
19945 v8::RegExp::kGlobal))
19946 .ToLocalChecked();
19947 CHECK(re->IsRegExp())do { if ((__builtin_expect(!!(!(re->IsRegExp())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19947, "Check failed: %s.", "re->IsRegExp()"
); } } while (0)
;
19948 CHECK(re->GetSource()->Equals(context.local(), v8_str("bar")).FromJust())do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("bar")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19948, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"bar\")).FromJust()"
); } } while (0)
;
19949 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kIgnoreCase | v8::RegExp::kGlobal), (static_cast<int>
(re->GetFlags())), "v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19950, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
19950 static_cast<int>(re->GetFlags()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kIgnoreCase | v8::RegExp::kGlobal), (static_cast<int>
(re->GetFlags())), "v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19950, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19951
19952 re = v8::RegExp::New(context.local(), v8_str("baz"),
19953 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
19954 v8::RegExp::kMultiline))
19955 .ToLocalChecked();
19956 CHECK(re->IsRegExp())do { if ((__builtin_expect(!!(!(re->IsRegExp())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19956, "Check failed: %s.", "re->IsRegExp()"
); } } while (0)
;
19957 CHECK(re->GetSource()->Equals(context.local(), v8_str("baz")).FromJust())do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("baz")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19957, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"baz\")).FromJust()"
); } } while (0)
;
19958 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kIgnoreCase | v8::RegExp::kMultiline), (static_cast<int>
(re->GetFlags())), "v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19959, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
19959 static_cast<int>(re->GetFlags()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kIgnoreCase | v8::RegExp::kMultiline), (static_cast<int>
(re->GetFlags())), "v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19959, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19960
19961 re = v8::RegExp::New(context.local(), v8_str("baz"),
19962 static_cast<v8::RegExp::Flags>(v8::RegExp::kUnicode |
19963 v8::RegExp::kSticky))
19964 .ToLocalChecked();
19965 CHECK(re->IsRegExp())do { if ((__builtin_expect(!!(!(re->IsRegExp())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19965, "Check failed: %s.", "re->IsRegExp()"
); } } while (0)
;
19966 CHECK(re->GetSource()->Equals(context.local(), v8_str("baz")).FromJust())do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("baz")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19966, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"baz\")).FromJust()"
); } } while (0)
;
19967 CHECK_EQ(v8::RegExp::kUnicode | v8::RegExp::kSticky,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kUnicode | v8::RegExp::kSticky), (static_cast<int>(re
->GetFlags())), "v8::RegExp::kUnicode | v8::RegExp::kSticky"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19968, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
19968 static_cast<int>(re->GetFlags()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kUnicode | v8::RegExp::kSticky), (static_cast<int>(re
->GetFlags())), "v8::RegExp::kUnicode | v8::RegExp::kSticky"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19968, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19969
19970 re = CompileRun("/quux/").As<v8::RegExp>();
19971 CHECK(re->IsRegExp())do { if ((__builtin_expect(!!(!(re->IsRegExp())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19971, "Check failed: %s.", "re->IsRegExp()"
); } } while (0)
;
19972 CHECK(re->GetSource()->Equals(context.local(), v8_str("quux")).FromJust())do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("quux")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19972, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"quux\")).FromJust()"
); } } while (0)
;
19973 CHECK_EQ(v8::RegExp::kNone, re->GetFlags())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kNone), (re->GetFlags()), "v8::RegExp::kNone" " " "==" " "
"re->GetFlags()")) { V8_Fatal("../test/cctest/test-api.cc"
, 19973, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19974
19975 re = CompileRun("/quux/gm").As<v8::RegExp>();
19976 CHECK(re->IsRegExp())do { if ((__builtin_expect(!!(!(re->IsRegExp())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19976, "Check failed: %s.", "re->IsRegExp()"
); } } while (0)
;
19977 CHECK(re->GetSource()->Equals(context.local(), v8_str("quux")).FromJust())do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("quux")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19977, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"quux\")).FromJust()"
); } } while (0)
;
19978 CHECK_EQ(v8::RegExp::kGlobal | v8::RegExp::kMultiline,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kGlobal | v8::RegExp::kMultiline), (static_cast<int>(
re->GetFlags())), "v8::RegExp::kGlobal | v8::RegExp::kMultiline"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19979, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
19979 static_cast<int>(re->GetFlags()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kGlobal | v8::RegExp::kMultiline), (static_cast<int>(
re->GetFlags())), "v8::RegExp::kGlobal | v8::RegExp::kMultiline"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19979, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
19980
19981 // Override the RegExp constructor and check the API constructor
19982 // still works.
19983 CompileRun("RegExp = function() {}");
19984
19985 re = v8::RegExp::New(context.local(), v8_str("foobar"), v8::RegExp::kNone)
19986 .ToLocalChecked();
19987 CHECK(re->IsRegExp())do { if ((__builtin_expect(!!(!(re->IsRegExp())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19987, "Check failed: %s.", "re->IsRegExp()"
); } } while (0)
;
19988 CHECK(re->GetSource()->Equals(context.local(), v8_str("foobar")).FromJust())do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("foobar")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19988, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"foobar\")).FromJust()"
); } } while (0)
;
19989 CHECK_EQ(v8::RegExp::kNone, re->GetFlags())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kNone), (re->GetFlags()), "v8::RegExp::kNone" " " "==" " "
"re->GetFlags()")) { V8_Fatal("../test/cctest/test-api.cc"
, 19989, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
19990
19991 re = v8::RegExp::New(context.local(), v8_str("foobarbaz"),
19992 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
19993 v8::RegExp::kMultiline))
19994 .ToLocalChecked();
19995 CHECK(re->IsRegExp())do { if ((__builtin_expect(!!(!(re->IsRegExp())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19995, "Check failed: %s.", "re->IsRegExp()"
); } } while (0)
;
19996 CHECK(do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("foobarbaz")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19997, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"foobarbaz\")).FromJust()"
); } } while (0)
19997 re->GetSource()->Equals(context.local(), v8_str("foobarbaz")).FromJust())do { if ((__builtin_expect(!!(!(re->GetSource()->Equals
(context.local(), v8_str("foobarbaz")).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 19997, "Check failed: %s.", "re->GetSource()->Equals(context.local(), v8_str(\"foobarbaz\")).FromJust()"
); } } while (0)
;
19998 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kIgnoreCase | v8::RegExp::kMultiline), (static_cast<int>
(re->GetFlags())), "v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19999, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
19999 static_cast<int>(re->GetFlags()))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (v8::RegExp
::kIgnoreCase | v8::RegExp::kMultiline), (static_cast<int>
(re->GetFlags())), "v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline"
" " "==" " " "static_cast<int>(re->GetFlags())")) {
V8_Fatal("../test/cctest/test-api.cc", 19999, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20000
20001 CHECK(context->Global()->Set(context.local(), v8_str("re"), re).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("re"), re).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20001, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"re\"), re).FromJust()"
); } } while (0)
;
20002 ExpectTrue("re.test('FoobarbaZ')");
20003
20004 // RegExps are objects on which you can set properties.
20005 re->Set(context.local(), v8_str("property"),
20006 v8::Integer::New(context->GetIsolate(), 32))
20007 .FromJust();
20008 v8::Local<v8::Value> value(CompileRun("re.property"));
20009 CHECK_EQ(32, value->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (32), (
value->Int32Value(context.local()).FromJust()), "32" " " "=="
" " "value->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 20009, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
20010
20011 v8::TryCatch try_catch(context->GetIsolate());
20012 CHECK(v8::RegExp::New(context.local(), v8_str("foo["), v8::RegExp::kNone)do { if ((__builtin_expect(!!(!(v8::RegExp::New(context.local
(), v8_str("foo["), v8::RegExp::kNone) .IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20013, "Check failed: %s.", "v8::RegExp::New(context.local(), v8_str(\"foo[\"), v8::RegExp::kNone) .IsEmpty()"
); } } while (0)
20013 .IsEmpty())do { if ((__builtin_expect(!!(!(v8::RegExp::New(context.local
(), v8_str("foo["), v8::RegExp::kNone) .IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20013, "Check failed: %s.", "v8::RegExp::New(context.local(), v8_str(\"foo[\"), v8::RegExp::kNone) .IsEmpty()"
); } } while (0)
;
20014 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 20014, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
20015 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("ex"), try_catch.Exception()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20017, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"ex\"), try_catch.Exception()) .FromJust()"
); } } while (0)
20016 ->Set(context.local(), v8_str("ex"), try_catch.Exception())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("ex"), try_catch.Exception()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20017, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"ex\"), try_catch.Exception()) .FromJust()"
); } } while (0)
20017 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("ex"), try_catch.Exception()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20017, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"ex\"), try_catch.Exception()) .FromJust()"
); } } while (0)
;
20018 ExpectTrue("ex instanceof SyntaxError");
20019}
20020
20021
20022THREADED_TEST(Equals)static void TestEquals(); RegisterThreadedTest register_Equals
(TestEquals, "Equals"); static void TestEquals(); CcTest register_test_Equals
(TestEquals, "../test/cctest/test-api.cc", "Equals", __null, true
, true); static void TestEquals()
{
20023 LocalContext localContext;
20024 v8::HandleScope handleScope(localContext->GetIsolate());
20025
20026 v8::Local<v8::Object> globalProxy = localContext->Global();
20027 v8::Local<Value> global = globalProxy->GetPrototype();
20028
20029 CHECK(global->StrictEquals(global))do { if ((__builtin_expect(!!(!(global->StrictEquals(global
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20029, "Check failed: %s."
, "global->StrictEquals(global)"); } } while (0)
;
20030 CHECK(!global->StrictEquals(globalProxy))do { if ((__builtin_expect(!!(!(!global->StrictEquals(globalProxy
))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20030, "Check failed: %s."
, "!global->StrictEquals(globalProxy)"); } } while (0)
;
20031 CHECK(!globalProxy->StrictEquals(global))do { if ((__builtin_expect(!!(!(!globalProxy->StrictEquals
(global))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20031
, "Check failed: %s.", "!globalProxy->StrictEquals(global)"
); } } while (0)
;
20032 CHECK(globalProxy->StrictEquals(globalProxy))do { if ((__builtin_expect(!!(!(globalProxy->StrictEquals(
globalProxy))), 0))) { V8_Fatal("../test/cctest/test-api.cc",
20032, "Check failed: %s.", "globalProxy->StrictEquals(globalProxy)"
); } } while (0)
;
20033
20034 CHECK(global->Equals(localContext.local(), global).FromJust())do { if ((__builtin_expect(!!(!(global->Equals(localContext
.local(), global).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20034, "Check failed: %s.", "global->Equals(localContext.local(), global).FromJust()"
); } } while (0)
;
20035 CHECK(!global->Equals(localContext.local(), globalProxy).FromJust())do { if ((__builtin_expect(!!(!(!global->Equals(localContext
.local(), globalProxy).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20035, "Check failed: %s.", "!global->Equals(localContext.local(), globalProxy).FromJust()"
); } } while (0)
;
20036 CHECK(!globalProxy->Equals(localContext.local(), global).FromJust())do { if ((__builtin_expect(!!(!(!globalProxy->Equals(localContext
.local(), global).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20036, "Check failed: %s.", "!globalProxy->Equals(localContext.local(), global).FromJust()"
); } } while (0)
;
20037 CHECK(globalProxy->Equals(localContext.local(), globalProxy).FromJust())do { if ((__builtin_expect(!!(!(globalProxy->Equals(localContext
.local(), globalProxy).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20037, "Check failed: %s.", "globalProxy->Equals(localContext.local(), globalProxy).FromJust()"
); } } while (0)
;
20038}
20039
20040
20041static void Getter(v8::Local<v8::Name> property,
20042 const v8::PropertyCallbackInfo<v8::Value>& info) {
20043 info.GetReturnValue().Set(v8_str("42!"));
20044}
20045
20046
20047static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
20048 v8::Local<v8::Array> result = v8::Array::New(info.GetIsolate());
20049 result->Set(info.GetIsolate()->GetCurrentContext(), 0,
20050 v8_str("universalAnswer"))
20051 .FromJust();
20052 info.GetReturnValue().Set(result);
20053}
20054
20055
20056TEST(NamedEnumeratorAndForIn)static void TestNamedEnumeratorAndForIn(); CcTest register_test_NamedEnumeratorAndForIn
(TestNamedEnumeratorAndForIn, "../test/cctest/test-api.cc", "NamedEnumeratorAndForIn"
, __null, true, true); static void TestNamedEnumeratorAndForIn
()
{
20057 LocalContext context;
20058 v8::Isolate* isolate = context->GetIsolate();
20059 v8::HandleScope handle_scope(isolate);
20060 v8::Context::Scope context_scope(context.local());
20061
20062 v8::Local<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(isolate);
20063 tmpl->SetHandler(v8::NamedPropertyHandlerConfiguration(Getter, NULL__null, NULL__null,
20064 NULL__null, Enumerator));
20065 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), tmpl->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20068, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), tmpl->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
20066 ->Set(context.local(), v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), tmpl->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20068, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), tmpl->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
20067 tmpl->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), tmpl->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20068, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), tmpl->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
20068 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("o"), tmpl->NewInstance(context.local
()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20068, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"o\"), tmpl->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20069 v8::Local<v8::Array> result = v8::Local<v8::Array>::Cast(
20070 CompileRun("var result = []; for (var k in o) result.push(k); result"));
20071 CHECK_EQ(1u, result->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1u), (
result->Length()), "1u" " " "==" " " "result->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20071, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20072 CHECK(v8_str("universalAnswer")do { if ((__builtin_expect(!!(!(v8_str("universalAnswer") ->
Equals(context.local(), result->Get(context.local(), 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20075, "Check failed: %s.", "v8_str(\"universalAnswer\") ->Equals(context.local(), result->Get(context.local(), 0).ToLocalChecked()) .FromJust()"
); } } while (0)
20073 ->Equals(context.local(),do { if ((__builtin_expect(!!(!(v8_str("universalAnswer") ->
Equals(context.local(), result->Get(context.local(), 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20075, "Check failed: %s.", "v8_str(\"universalAnswer\") ->Equals(context.local(), result->Get(context.local(), 0).ToLocalChecked()) .FromJust()"
); } } while (0)
20074 result->Get(context.local(), 0).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("universalAnswer") ->
Equals(context.local(), result->Get(context.local(), 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20075, "Check failed: %s.", "v8_str(\"universalAnswer\") ->Equals(context.local(), result->Get(context.local(), 0).ToLocalChecked()) .FromJust()"
); } } while (0)
20075 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("universalAnswer") ->
Equals(context.local(), result->Get(context.local(), 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20075, "Check failed: %s.", "v8_str(\"universalAnswer\") ->Equals(context.local(), result->Get(context.local(), 0).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20076}
20077
20078
20079TEST(DefinePropertyPostDetach)static void TestDefinePropertyPostDetach(); CcTest register_test_DefinePropertyPostDetach
(TestDefinePropertyPostDetach, "../test/cctest/test-api.cc", "DefinePropertyPostDetach"
, __null, true, true); static void TestDefinePropertyPostDetach
()
{
20080 LocalContext context;
20081 v8::HandleScope scope(context->GetIsolate());
20082 v8::Local<v8::Object> proxy = context->Global();
20083 v8::Local<v8::Function> define_property =
20084 CompileRun(
20085 "(function() {"
20086 " Object.defineProperty("
20087 " this,"
20088 " 1,"
20089 " { configurable: true, enumerable: true, value: 3 });"
20090 "})")
20091 .As<Function>();
20092 context->DetachGlobal();
20093 CHECK(define_property->Call(context.local(), proxy, 0, NULL).IsEmpty())do { if ((__builtin_expect(!!(!(define_property->Call(context
.local(), proxy, 0, __null).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20093, "Check failed: %s.", "define_property->Call(context.local(), proxy, 0, NULL).IsEmpty()"
); } } while (0)
;
20094}
20095
20096
20097static void InstallContextId(v8::Local<Context> context, int id) {
20098 Context::Scope scope(context);
20099 CHECK(CompileRun("Object.prototype")do { if ((__builtin_expect(!!(!(CompileRun("Object.prototype"
) .As<Object>() ->Set(context, v8_str("context_id"),
v8::Integer::New(context->GetIsolate(), id)) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20103, "Check failed: %s."
, "CompileRun(\"Object.prototype\") .As<Object>() ->Set(context, v8_str(\"context_id\"), v8::Integer::New(context->GetIsolate(), id)) .FromJust()"
); } } while (0)
20100 .As<Object>()do { if ((__builtin_expect(!!(!(CompileRun("Object.prototype"
) .As<Object>() ->Set(context, v8_str("context_id"),
v8::Integer::New(context->GetIsolate(), id)) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20103, "Check failed: %s."
, "CompileRun(\"Object.prototype\") .As<Object>() ->Set(context, v8_str(\"context_id\"), v8::Integer::New(context->GetIsolate(), id)) .FromJust()"
); } } while (0)
20101 ->Set(context, v8_str("context_id"),do { if ((__builtin_expect(!!(!(CompileRun("Object.prototype"
) .As<Object>() ->Set(context, v8_str("context_id"),
v8::Integer::New(context->GetIsolate(), id)) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20103, "Check failed: %s."
, "CompileRun(\"Object.prototype\") .As<Object>() ->Set(context, v8_str(\"context_id\"), v8::Integer::New(context->GetIsolate(), id)) .FromJust()"
); } } while (0)
20102 v8::Integer::New(context->GetIsolate(), id))do { if ((__builtin_expect(!!(!(CompileRun("Object.prototype"
) .As<Object>() ->Set(context, v8_str("context_id"),
v8::Integer::New(context->GetIsolate(), id)) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20103, "Check failed: %s."
, "CompileRun(\"Object.prototype\") .As<Object>() ->Set(context, v8_str(\"context_id\"), v8::Integer::New(context->GetIsolate(), id)) .FromJust()"
); } } while (0)
20103 .FromJust())do { if ((__builtin_expect(!!(!(CompileRun("Object.prototype"
) .As<Object>() ->Set(context, v8_str("context_id"),
v8::Integer::New(context->GetIsolate(), id)) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20103, "Check failed: %s."
, "CompileRun(\"Object.prototype\") .As<Object>() ->Set(context, v8_str(\"context_id\"), v8::Integer::New(context->GetIsolate(), id)) .FromJust()"
); } } while (0)
;
20104}
20105
20106
20107static void CheckContextId(v8::Local<Object> object, int expected) {
20108 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
20109 CHECK_EQ(expected, object->Get(context, v8_str("context_id"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected
), (object->Get(context, v8_str("context_id")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "expected" " " "=="
" " "object->Get(context, v8_str(\"context_id\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20112, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
20110 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected
), (object->Get(context, v8_str("context_id")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "expected" " " "=="
" " "object->Get(context, v8_str(\"context_id\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20112, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
20111 ->Int32Value(context)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected
), (object->Get(context, v8_str("context_id")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "expected" " " "=="
" " "object->Get(context, v8_str(\"context_id\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20112, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
20112 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (expected
), (object->Get(context, v8_str("context_id")) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "expected" " " "=="
" " "object->Get(context, v8_str(\"context_id\")) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20112, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20113}
20114
20115
20116THREADED_TEST(CreationContext)static void TestCreationContext(); RegisterThreadedTest register_CreationContext
(TestCreationContext, "CreationContext"); static void TestCreationContext
(); CcTest register_test_CreationContext(TestCreationContext,
"../test/cctest/test-api.cc", "CreationContext", __null, true
, true); static void TestCreationContext()
{
20117 v8::Isolate* isolate = CcTest::isolate();
20118 HandleScope handle_scope(isolate);
20119 Local<Context> context1 = Context::New(isolate);
20120 InstallContextId(context1, 1);
20121 Local<Context> context2 = Context::New(isolate);
20122 InstallContextId(context2, 2);
20123 Local<Context> context3 = Context::New(isolate);
20124 InstallContextId(context3, 3);
20125
20126 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate);
20127
20128 Local<Object> object1;
20129 Local<Function> func1;
20130 {
20131 Context::Scope scope(context1);
20132 object1 = Object::New(isolate);
20133 func1 = tmpl->GetFunction(context1).ToLocalChecked();
20134 }
20135
20136 Local<Object> object2;
20137 Local<Function> func2;
20138 {
20139 Context::Scope scope(context2);
20140 object2 = Object::New(isolate);
20141 func2 = tmpl->GetFunction(context2).ToLocalChecked();
20142 }
20143
20144 Local<Object> instance1;
20145 Local<Object> instance2;
20146
20147 {
20148 Context::Scope scope(context3);
20149 instance1 = func1->NewInstance(context3).ToLocalChecked();
20150 instance2 = func2->NewInstance(context3).ToLocalChecked();
20151 }
20152
20153 {
20154 Local<Context> other_context = Context::New(isolate);
20155 Context::Scope scope(other_context);
20156 CHECK(object1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(object1->CreationContext()
== context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc",
20156, "Check failed: %s.", "object1->CreationContext() == context1"
); } } while (0)
;
20157 CheckContextId(object1, 1);
20158 CHECK(func1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(func1->CreationContext() ==
context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20158
, "Check failed: %s.", "func1->CreationContext() == context1"
); } } while (0)
;
20159 CheckContextId(func1, 1);
20160 CHECK(instance1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(instance1->CreationContext
() == context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20160, "Check failed: %s.", "instance1->CreationContext() == context1"
); } } while (0)
;
20161 CheckContextId(instance1, 1);
20162 CHECK(object2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(object2->CreationContext()
== context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc",
20162, "Check failed: %s.", "object2->CreationContext() == context2"
); } } while (0)
;
20163 CheckContextId(object2, 2);
20164 CHECK(func2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(func2->CreationContext() ==
context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20164
, "Check failed: %s.", "func2->CreationContext() == context2"
); } } while (0)
;
20165 CheckContextId(func2, 2);
20166 CHECK(instance2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(instance2->CreationContext
() == context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20166, "Check failed: %s.", "instance2->CreationContext() == context2"
); } } while (0)
;
20167 CheckContextId(instance2, 2);
20168 }
20169
20170 {
20171 Context::Scope scope(context1);
20172 CHECK(object1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(object1->CreationContext()
== context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc",
20172, "Check failed: %s.", "object1->CreationContext() == context1"
); } } while (0)
;
20173 CheckContextId(object1, 1);
20174 CHECK(func1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(func1->CreationContext() ==
context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20174
, "Check failed: %s.", "func1->CreationContext() == context1"
); } } while (0)
;
20175 CheckContextId(func1, 1);
20176 CHECK(instance1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(instance1->CreationContext
() == context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20176, "Check failed: %s.", "instance1->CreationContext() == context1"
); } } while (0)
;
20177 CheckContextId(instance1, 1);
20178 CHECK(object2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(object2->CreationContext()
== context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc",
20178, "Check failed: %s.", "object2->CreationContext() == context2"
); } } while (0)
;
20179 CheckContextId(object2, 2);
20180 CHECK(func2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(func2->CreationContext() ==
context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20180
, "Check failed: %s.", "func2->CreationContext() == context2"
); } } while (0)
;
20181 CheckContextId(func2, 2);
20182 CHECK(instance2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(instance2->CreationContext
() == context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20182, "Check failed: %s.", "instance2->CreationContext() == context2"
); } } while (0)
;
20183 CheckContextId(instance2, 2);
20184 }
20185
20186 {
20187 Context::Scope scope(context2);
20188 CHECK(object1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(object1->CreationContext()
== context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc",
20188, "Check failed: %s.", "object1->CreationContext() == context1"
); } } while (0)
;
20189 CheckContextId(object1, 1);
20190 CHECK(func1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(func1->CreationContext() ==
context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20190
, "Check failed: %s.", "func1->CreationContext() == context1"
); } } while (0)
;
20191 CheckContextId(func1, 1);
20192 CHECK(instance1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(instance1->CreationContext
() == context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20192, "Check failed: %s.", "instance1->CreationContext() == context1"
); } } while (0)
;
20193 CheckContextId(instance1, 1);
20194 CHECK(object2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(object2->CreationContext()
== context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc",
20194, "Check failed: %s.", "object2->CreationContext() == context2"
); } } while (0)
;
20195 CheckContextId(object2, 2);
20196 CHECK(func2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(func2->CreationContext() ==
context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20196
, "Check failed: %s.", "func2->CreationContext() == context2"
); } } while (0)
;
20197 CheckContextId(func2, 2);
20198 CHECK(instance2->CreationContext() == context2)do { if ((__builtin_expect(!!(!(instance2->CreationContext
() == context2)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20198, "Check failed: %s.", "instance2->CreationContext() == context2"
); } } while (0)
;
20199 CheckContextId(instance2, 2);
20200 }
20201}
20202
20203
20204THREADED_TEST(CreationContextOfJsFunction)static void TestCreationContextOfJsFunction(); RegisterThreadedTest
register_CreationContextOfJsFunction(TestCreationContextOfJsFunction
, "CreationContextOfJsFunction"); static void TestCreationContextOfJsFunction
(); CcTest register_test_CreationContextOfJsFunction(TestCreationContextOfJsFunction
, "../test/cctest/test-api.cc", "CreationContextOfJsFunction"
, __null, true, true); static void TestCreationContextOfJsFunction
()
{
20205 HandleScope handle_scope(CcTest::isolate());
20206 Local<Context> context = Context::New(CcTest::isolate());
20207 InstallContextId(context, 1);
20208
20209 Local<Object> function;
20210 {
20211 Context::Scope scope(context);
20212 function = CompileRun("function foo() {}; foo").As<Object>();
20213 }
20214
20215 Local<Context> other_context = Context::New(CcTest::isolate());
20216 Context::Scope scope(other_context);
20217 CHECK(function->CreationContext() == context)do { if ((__builtin_expect(!!(!(function->CreationContext(
) == context)), 0))) { V8_Fatal("../test/cctest/test-api.cc",
20217, "Check failed: %s.", "function->CreationContext() == context"
); } } while (0)
;
20218 CheckContextId(function, 1);
20219}
20220
20221
20222THREADED_TEST(CreationContextOfJsBoundFunction)static void TestCreationContextOfJsBoundFunction(); RegisterThreadedTest
register_CreationContextOfJsBoundFunction(TestCreationContextOfJsBoundFunction
, "CreationContextOfJsBoundFunction"); static void TestCreationContextOfJsBoundFunction
(); CcTest register_test_CreationContextOfJsBoundFunction(TestCreationContextOfJsBoundFunction
, "../test/cctest/test-api.cc", "CreationContextOfJsBoundFunction"
, __null, true, true); static void TestCreationContextOfJsBoundFunction
()
{
20223 HandleScope handle_scope(CcTest::isolate());
20224 Local<Context> context1 = Context::New(CcTest::isolate());
20225 InstallContextId(context1, 1);
20226 Local<Context> context2 = Context::New(CcTest::isolate());
20227 InstallContextId(context2, 2);
20228
20229 Local<Function> target_function;
20230 {
20231 Context::Scope scope(context1);
20232 target_function = CompileRun("function foo() {}; foo").As<Function>();
20233 }
20234
20235 Local<Function> bound_function1, bound_function2;
20236 {
20237 Context::Scope scope(context2);
20238 CHECK(context2->Global()do { if ((__builtin_expect(!!(!(context2->Global() ->Set
(context2, v8_str("foo"), target_function) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 20240, "Check failed: %s."
, "context2->Global() ->Set(context2, v8_str(\"foo\"), target_function) .FromJust()"
); } } while (0)
20239 ->Set(context2, v8_str("foo"), target_function)do { if ((__builtin_expect(!!(!(context2->Global() ->Set
(context2, v8_str("foo"), target_function) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 20240, "Check failed: %s."
, "context2->Global() ->Set(context2, v8_str(\"foo\"), target_function) .FromJust()"
); } } while (0)
20240 .FromJust())do { if ((__builtin_expect(!!(!(context2->Global() ->Set
(context2, v8_str("foo"), target_function) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 20240, "Check failed: %s."
, "context2->Global() ->Set(context2, v8_str(\"foo\"), target_function) .FromJust()"
); } } while (0)
;
20241 bound_function1 = CompileRun("foo.bind(1)").As<Function>();
20242 bound_function2 =
20243 CompileRun("Function.prototype.bind.call(foo, 2)").As<Function>();
20244 }
20245
20246 Local<Context> other_context = Context::New(CcTest::isolate());
20247 Context::Scope scope(other_context);
20248 CHECK(bound_function1->CreationContext() == context1)do { if ((__builtin_expect(!!(!(bound_function1->CreationContext
() == context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20248, "Check failed: %s.", "bound_function1->CreationContext() == context1"
); } } while (0)
;
20249 CheckContextId(bound_function1, 1);
20250 CHECK(bound_function2->CreationContext() == context1)do { if ((__builtin_expect(!!(!(bound_function2->CreationContext
() == context1)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20250, "Check failed: %s.", "bound_function2->CreationContext() == context1"
); } } while (0)
;
20251 CheckContextId(bound_function2, 1);
20252}
20253
20254
20255void HasOwnPropertyIndexedPropertyGetter(
20256 uint32_t index,
20257 const v8::PropertyCallbackInfo<v8::Value>& info) {
20258 if (index == 42) info.GetReturnValue().Set(v8_str("yes"));
20259}
20260
20261
20262void HasOwnPropertyNamedPropertyGetter(
20263 Local<Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) {
20264 if (property->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("foo"))
20265 .FromJust()) {
20266 info.GetReturnValue().Set(v8_str("yes"));
20267 }
20268}
20269
20270
20271void HasOwnPropertyIndexedPropertyQuery(
20272 uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) {
20273 if (index == 42) info.GetReturnValue().Set(1);
20274}
20275
20276
20277void HasOwnPropertyNamedPropertyQuery(
20278 Local<Name> property, const v8::PropertyCallbackInfo<v8::Integer>& info) {
20279 if (property->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("foo"))
20280 .FromJust()) {
20281 info.GetReturnValue().Set(1);
20282 }
20283}
20284
20285
20286void HasOwnPropertyNamedPropertyQuery2(
20287 Local<Name> property, const v8::PropertyCallbackInfo<v8::Integer>& info) {
20288 if (property->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("bar"))
20289 .FromJust()) {
20290 info.GetReturnValue().Set(1);
20291 }
20292}
20293
20294
20295void HasOwnPropertyAccessorGetter(
20296 Local<String> property,
20297 const v8::PropertyCallbackInfo<v8::Value>& info) {
20298 info.GetReturnValue().Set(v8_str("yes"));
20299}
20300
20301
20302TEST(HasOwnProperty)static void TestHasOwnProperty(); CcTest register_test_HasOwnProperty
(TestHasOwnProperty, "../test/cctest/test-api.cc", "HasOwnProperty"
, __null, true, true); static void TestHasOwnProperty()
{
20303 LocalContext env;
20304 v8::Isolate* isolate = env->GetIsolate();
20305 v8::HandleScope scope(isolate);
20306 { // Check normal properties and defined getters.
20307 Local<Value> value = CompileRun(
20308 "function Foo() {"
20309 " this.foo = 11;"
20310 " this.__defineGetter__('baz', function() { return 1; });"
20311 "};"
20312 "function Bar() { "
20313 " this.bar = 13;"
20314 " this.__defineGetter__('bla', function() { return 2; });"
20315 "};"
20316 "Bar.prototype = new Foo();"
20317 "new Bar();");
20318 CHECK(value->IsObject())do { if ((__builtin_expect(!!(!(value->IsObject())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 20318, "Check failed: %s."
, "value->IsObject()"); } } while (0)
;
20319 Local<Object> object = value->ToObject(env.local()).ToLocalChecked();
20320 CHECK(object->Has(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(object->Has(env.local(), v8_str
("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20320, "Check failed: %s.", "object->Has(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
20321 CHECK(!object->HasOwnProperty(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(!object->HasOwnProperty(env
.local(), v8_str("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20321, "Check failed: %s.", "!object->HasOwnProperty(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
20322 CHECK(object->HasOwnProperty(env.local(), v8_str("bar")).FromJust())do { if ((__builtin_expect(!!(!(object->HasOwnProperty(env
.local(), v8_str("bar")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20322, "Check failed: %s.", "object->HasOwnProperty(env.local(), v8_str(\"bar\")).FromJust()"
); } } while (0)
;
20323 CHECK(object->Has(env.local(), v8_str("baz")).FromJust())do { if ((__builtin_expect(!!(!(object->Has(env.local(), v8_str
("baz")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20323, "Check failed: %s.", "object->Has(env.local(), v8_str(\"baz\")).FromJust()"
); } } while (0)
;
20324 CHECK(!object->HasOwnProperty(env.local(), v8_str("baz")).FromJust())do { if ((__builtin_expect(!!(!(!object->HasOwnProperty(env
.local(), v8_str("baz")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20324, "Check failed: %s.", "!object->HasOwnProperty(env.local(), v8_str(\"baz\")).FromJust()"
); } } while (0)
;
20325 CHECK(object->HasOwnProperty(env.local(), v8_str("bla")).FromJust())do { if ((__builtin_expect(!!(!(object->HasOwnProperty(env
.local(), v8_str("bla")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20325, "Check failed: %s.", "object->HasOwnProperty(env.local(), v8_str(\"bla\")).FromJust()"
); } } while (0)
;
20326 }
20327 { // Check named getter interceptors.
20328 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20329 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
20330 HasOwnPropertyNamedPropertyGetter));
20331 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20332 CHECK(!instance->HasOwnProperty(env.local(), v8_str("42")).FromJust())do { if ((__builtin_expect(!!(!(!instance->HasOwnProperty(
env.local(), v8_str("42")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20332, "Check failed: %s.", "!instance->HasOwnProperty(env.local(), v8_str(\"42\")).FromJust()"
); } } while (0)
;
20333 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(instance->HasOwnProperty(env
.local(), v8_str("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20333, "Check failed: %s.", "instance->HasOwnProperty(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
20334 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust())do { if ((__builtin_expect(!!(!(!instance->HasOwnProperty(
env.local(), v8_str("bar")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20334, "Check failed: %s.", "!instance->HasOwnProperty(env.local(), v8_str(\"bar\")).FromJust()"
); } } while (0)
;
20335 }
20336 { // Check indexed getter interceptors.
20337 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20338 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration(
20339 HasOwnPropertyIndexedPropertyGetter));
20340 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20341 CHECK(instance->HasOwnProperty(env.local(), v8_str("42")).FromJust())do { if ((__builtin_expect(!!(!(instance->HasOwnProperty(env
.local(), v8_str("42")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20341, "Check failed: %s.", "instance->HasOwnProperty(env.local(), v8_str(\"42\")).FromJust()"
); } } while (0)
;
20342 CHECK(!instance->HasOwnProperty(env.local(), v8_str("43")).FromJust())do { if ((__builtin_expect(!!(!(!instance->HasOwnProperty(
env.local(), v8_str("43")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20342, "Check failed: %s.", "!instance->HasOwnProperty(env.local(), v8_str(\"43\")).FromJust()"
); } } while (0)
;
20343 CHECK(!instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(!instance->HasOwnProperty(
env.local(), v8_str("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20343, "Check failed: %s.", "!instance->HasOwnProperty(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
20344 }
20345 { // Check named query interceptors.
20346 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20347 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
20348 0, 0, HasOwnPropertyNamedPropertyQuery));
20349 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20350 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(instance->HasOwnProperty(env
.local(), v8_str("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20350, "Check failed: %s.", "instance->HasOwnProperty(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
20351 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust())do { if ((__builtin_expect(!!(!(!instance->HasOwnProperty(
env.local(), v8_str("bar")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20351, "Check failed: %s.", "!instance->HasOwnProperty(env.local(), v8_str(\"bar\")).FromJust()"
); } } while (0)
;
20352 }
20353 { // Check indexed query interceptors.
20354 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20355 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration(
20356 0, 0, HasOwnPropertyIndexedPropertyQuery));
20357 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20358 CHECK(instance->HasOwnProperty(env.local(), v8_str("42")).FromJust())do { if ((__builtin_expect(!!(!(instance->HasOwnProperty(env
.local(), v8_str("42")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20358, "Check failed: %s.", "instance->HasOwnProperty(env.local(), v8_str(\"42\")).FromJust()"
); } } while (0)
;
20359 CHECK(!instance->HasOwnProperty(env.local(), v8_str("41")).FromJust())do { if ((__builtin_expect(!!(!(!instance->HasOwnProperty(
env.local(), v8_str("41")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20359, "Check failed: %s.", "!instance->HasOwnProperty(env.local(), v8_str(\"41\")).FromJust()"
); } } while (0)
;
20360 }
20361 { // Check callbacks.
20362 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20363 templ->SetAccessor(v8_str("foo"), HasOwnPropertyAccessorGetter);
20364 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20365 CHECK(instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(instance->HasOwnProperty(env
.local(), v8_str("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20365, "Check failed: %s.", "instance->HasOwnProperty(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
20366 CHECK(!instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust())do { if ((__builtin_expect(!!(!(!instance->HasOwnProperty(
env.local(), v8_str("bar")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20366, "Check failed: %s.", "!instance->HasOwnProperty(env.local(), v8_str(\"bar\")).FromJust()"
); } } while (0)
;
20367 }
20368 { // Check that query wins on disagreement.
20369 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20370 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(
20371 HasOwnPropertyNamedPropertyGetter, 0,
20372 HasOwnPropertyNamedPropertyQuery2));
20373 Local<Object> instance = templ->NewInstance(env.local()).ToLocalChecked();
20374 CHECK(!instance->HasOwnProperty(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(!instance->HasOwnProperty(
env.local(), v8_str("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20374, "Check failed: %s.", "!instance->HasOwnProperty(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
20375 CHECK(instance->HasOwnProperty(env.local(), v8_str("bar")).FromJust())do { if ((__builtin_expect(!!(!(instance->HasOwnProperty(env
.local(), v8_str("bar")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20375, "Check failed: %s.", "instance->HasOwnProperty(env.local(), v8_str(\"bar\")).FromJust()"
); } } while (0)
;
20376 }
20377}
20378
20379
20380TEST(IndexedInterceptorWithStringProto)static void TestIndexedInterceptorWithStringProto(); CcTest register_test_IndexedInterceptorWithStringProto
(TestIndexedInterceptorWithStringProto, "../test/cctest/test-api.cc"
, "IndexedInterceptorWithStringProto", __null, true, true); static
void TestIndexedInterceptorWithStringProto()
{
20381 v8::Isolate* isolate = CcTest::isolate();
20382 v8::HandleScope scope(isolate);
20383 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20384 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration(
20385 NULL__null, NULL__null, HasOwnPropertyIndexedPropertyQuery));
20386 LocalContext context;
20387 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20390, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
20388 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20390, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
20389 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20390, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
20390 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20390, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20391 CompileRun("var s = new String('foobar'); obj.__proto__ = s;");
20392 // These should be intercepted.
20393 CHECK(CompileRun("42 in obj")->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("42 in obj")->BooleanValue
(context.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20393, "Check failed: %s.", "CompileRun(\"42 in obj\")->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
20394 CHECK(CompileRun("'42' in obj")->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("'42' in obj")->
BooleanValue(context.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20394, "Check failed: %s.", "CompileRun(\"'42' in obj\")->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
20395 // These should fall through to the String prototype.
20396 CHECK(CompileRun("0 in obj")->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("0 in obj")->BooleanValue
(context.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20396, "Check failed: %s.", "CompileRun(\"0 in obj\")->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
20397 CHECK(CompileRun("'0' in obj")->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(CompileRun("'0' in obj")->
BooleanValue(context.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20397, "Check failed: %s.", "CompileRun(\"'0' in obj\")->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
20398 // And these should both fail.
20399 CHECK(!CompileRun("32 in obj")->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(!CompileRun("32 in obj")->
BooleanValue(context.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20399, "Check failed: %s.", "!CompileRun(\"32 in obj\")->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
20400 CHECK(!CompileRun("'32' in obj")->BooleanValue(context.local()).FromJust())do { if ((__builtin_expect(!!(!(!CompileRun("'32' in obj")->
BooleanValue(context.local()).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20400, "Check failed: %s.", "!CompileRun(\"'32' in obj\")->BooleanValue(context.local()).FromJust()"
); } } while (0)
;
20401}
20402
20403
20404void CheckCodeGenerationAllowed() {
20405 Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
20406 Local<Value> result = CompileRun("eval('42')");
20407 CHECK_EQ(42, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context).FromJust()), "42" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 20407, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20408 result = CompileRun("(function(e) { return e('42'); })(eval)");
20409 CHECK_EQ(42, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context).FromJust()), "42" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 20409, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20410 result = CompileRun("var f = new Function('return 42'); f()");
20411 CHECK_EQ(42, result->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context).FromJust()), "42" " " "==" " "
"result->Int32Value(context).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 20411, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20412}
20413
20414
20415void CheckCodeGenerationDisallowed() {
20416 TryCatch try_catch(CcTest::isolate());
20417
20418 Local<Value> result = CompileRun("eval('42')");
20419 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20419, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
20420 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 20420, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
20421 try_catch.Reset();
20422
20423 result = CompileRun("(function(e) { return e('42'); })(eval)");
20424 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20424, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
20425 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 20425, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
20426 try_catch.Reset();
20427
20428 result = CompileRun("var f = new Function('return 42'); f()");
20429 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20429, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
20430 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 20430, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
20431}
20432
20433
20434bool CodeGenerationAllowed(Local<Context> context) {
20435 ApiTestFuzzer::Fuzz();
20436 return true;
20437}
20438
20439
20440bool CodeGenerationDisallowed(Local<Context> context) {
20441 ApiTestFuzzer::Fuzz();
20442 return false;
20443}
20444
20445
20446THREADED_TEST(AllowCodeGenFromStrings)static void TestAllowCodeGenFromStrings(); RegisterThreadedTest
register_AllowCodeGenFromStrings(TestAllowCodeGenFromStrings
, "AllowCodeGenFromStrings"); static void TestAllowCodeGenFromStrings
(); CcTest register_test_AllowCodeGenFromStrings(TestAllowCodeGenFromStrings
, "../test/cctest/test-api.cc", "AllowCodeGenFromStrings", __null
, true, true); static void TestAllowCodeGenFromStrings()
{
20447 LocalContext context;
20448 v8::HandleScope scope(context->GetIsolate());
20449
20450 // eval and the Function constructor allowed by default.
20451 CHECK(context->IsCodeGenerationFromStringsAllowed())do { if ((__builtin_expect(!!(!(context->IsCodeGenerationFromStringsAllowed
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20451, "Check failed: %s."
, "context->IsCodeGenerationFromStringsAllowed()"); } } while
(0)
;
20452 CheckCodeGenerationAllowed();
20453
20454 // Disallow eval and the Function constructor.
20455 context->AllowCodeGenerationFromStrings(false);
20456 CHECK(!context->IsCodeGenerationFromStringsAllowed())do { if ((__builtin_expect(!!(!(!context->IsCodeGenerationFromStringsAllowed
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20456, "Check failed: %s."
, "!context->IsCodeGenerationFromStringsAllowed()"); } } while
(0)
;
20457 CheckCodeGenerationDisallowed();
20458
20459 // Allow again.
20460 context->AllowCodeGenerationFromStrings(true);
20461 CheckCodeGenerationAllowed();
20462
20463 // Disallow but setting a global callback that will allow the calls.
20464 context->AllowCodeGenerationFromStrings(false);
20465 context->GetIsolate()->SetAllowCodeGenerationFromStringsCallback(
20466 &CodeGenerationAllowed);
20467 CHECK(!context->IsCodeGenerationFromStringsAllowed())do { if ((__builtin_expect(!!(!(!context->IsCodeGenerationFromStringsAllowed
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20467, "Check failed: %s."
, "!context->IsCodeGenerationFromStringsAllowed()"); } } while
(0)
;
20468 CheckCodeGenerationAllowed();
20469
20470 // Set a callback that disallows the code generation.
20471 context->GetIsolate()->SetAllowCodeGenerationFromStringsCallback(
20472 &CodeGenerationDisallowed);
20473 CHECK(!context->IsCodeGenerationFromStringsAllowed())do { if ((__builtin_expect(!!(!(!context->IsCodeGenerationFromStringsAllowed
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20473, "Check failed: %s."
, "!context->IsCodeGenerationFromStringsAllowed()"); } } while
(0)
;
20474 CheckCodeGenerationDisallowed();
20475}
20476
20477
20478TEST(SetErrorMessageForCodeGenFromStrings)static void TestSetErrorMessageForCodeGenFromStrings(); CcTest
register_test_SetErrorMessageForCodeGenFromStrings(TestSetErrorMessageForCodeGenFromStrings
, "../test/cctest/test-api.cc", "SetErrorMessageForCodeGenFromStrings"
, __null, true, true); static void TestSetErrorMessageForCodeGenFromStrings
()
{
20479 LocalContext context;
20480 v8::HandleScope scope(context->GetIsolate());
20481 TryCatch try_catch(context->GetIsolate());
20482
20483 Local<String> message = v8_str("Message");
20484 Local<String> expected_message = v8_str("Uncaught EvalError: Message");
20485 context->GetIsolate()->SetAllowCodeGenerationFromStringsCallback(
20486 &CodeGenerationDisallowed);
20487 context->AllowCodeGenerationFromStrings(false);
20488 context->SetErrorMessageForCodeGenerationFromStrings(message);
20489 Local<Value> result = CompileRun("eval('42')");
20490 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20490, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
20491 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 20491, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
20492 Local<String> actual_message = try_catch.Message()->Get();
20493 CHECK(expected_message->Equals(context.local(), actual_message).FromJust())do { if ((__builtin_expect(!!(!(expected_message->Equals(context
.local(), actual_message).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20493, "Check failed: %s.", "expected_message->Equals(context.local(), actual_message).FromJust()"
); } } while (0)
;
20494}
20495
20496
20497static void NonObjectThis(const v8::FunctionCallbackInfo<v8::Value>& args) {
20498}
20499
20500
20501THREADED_TEST(CallAPIFunctionOnNonObject)static void TestCallAPIFunctionOnNonObject(); RegisterThreadedTest
register_CallAPIFunctionOnNonObject(TestCallAPIFunctionOnNonObject
, "CallAPIFunctionOnNonObject"); static void TestCallAPIFunctionOnNonObject
(); CcTest register_test_CallAPIFunctionOnNonObject(TestCallAPIFunctionOnNonObject
, "../test/cctest/test-api.cc", "CallAPIFunctionOnNonObject",
__null, true, true); static void TestCallAPIFunctionOnNonObject
()
{
20502 LocalContext context;
20503 v8::Isolate* isolate = context->GetIsolate();
20504 v8::HandleScope scope(isolate);
20505 Local<FunctionTemplate> templ =
20506 v8::FunctionTemplate::New(isolate, NonObjectThis);
20507 Local<Function> function =
20508 templ->GetFunction(context.local()).ToLocalChecked();
20509 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), function) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 20511, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"f\"), function) .FromJust()"
); } } while (0)
20510 ->Set(context.local(), v8_str("f"), function)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), function) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 20511, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"f\"), function) .FromJust()"
); } } while (0)
20511 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), function) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 20511, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"f\"), function) .FromJust()"
); } } while (0)
;
20512 TryCatch try_catch(isolate);
20513 CompileRun("f.call(2)");
20514}
20515
20516
20517// Regression test for issue 1470.
20518THREADED_TEST(ReadOnlyIndexedProperties)static void TestReadOnlyIndexedProperties(); RegisterThreadedTest
register_ReadOnlyIndexedProperties(TestReadOnlyIndexedProperties
, "ReadOnlyIndexedProperties"); static void TestReadOnlyIndexedProperties
(); CcTest register_test_ReadOnlyIndexedProperties(TestReadOnlyIndexedProperties
, "../test/cctest/test-api.cc", "ReadOnlyIndexedProperties", __null
, true, true); static void TestReadOnlyIndexedProperties()
{
20519 v8::Isolate* isolate = CcTest::isolate();
20520 v8::HandleScope scope(isolate);
20521 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
20522
20523 LocalContext context;
20524 Local<v8::Object> obj = templ->NewInstance(context.local()).ToLocalChecked();
20525 CHECK(context->Global()->Set(context.local(), v8_str("obj"), obj).FromJust())do { if ((__builtin_expect(!!(!(context->Global()->Set(
context.local(), v8_str("obj"), obj).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20525, "Check failed: %s.", "context->Global()->Set(context.local(), v8_str(\"obj\"), obj).FromJust()"
); } } while (0)
;
20526 obj->DefineOwnProperty(context.local(), v8_str("1"), v8_str("DONT_CHANGE"),
20527 v8::ReadOnly)
20528 .FromJust();
20529 obj->Set(context.local(), v8_str("1"), v8_str("foobar")).FromJust();
20530 CHECK(v8_str("DONT_CHANGE")do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("1")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20533, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
20531 ->Equals(context.local(),do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("1")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20533, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
20532 obj->Get(context.local(), v8_str("1")).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("1")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20533, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
20533 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("1")).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20533, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"1\")).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20534 obj->DefineOwnProperty(context.local(), v8_str("2"), v8_str("DONT_CHANGE"),
20535 v8::ReadOnly)
20536 .FromJust();
20537 obj->Set(context.local(), v8_num(2), v8_str("foobar")).FromJust();
20538 CHECK(v8_str("DONT_CHANGE")do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_num(2)).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20541, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_num(2)).ToLocalChecked()) .FromJust()"
); } } while (0)
20539 ->Equals(context.local(),do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_num(2)).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20541, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_num(2)).ToLocalChecked()) .FromJust()"
); } } while (0)
20540 obj->Get(context.local(), v8_num(2)).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_num(2)).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20541, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_num(2)).ToLocalChecked()) .FromJust()"
); } } while (0)
20541 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_num(2)).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20541, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_num(2)).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20542
20543 // Test non-smi case.
20544 obj->DefineOwnProperty(context.local(), v8_str("2000000000"),
20545 v8_str("DONT_CHANGE"), v8::ReadOnly)
20546 .FromJust();
20547 obj->Set(context.local(), v8_str("2000000000"), v8_str("foobar")).FromJust();
20548 CHECK(v8_str("DONT_CHANGE")do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("2000000000"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20552, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"2000000000\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
20549 ->Equals(context.local(),do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("2000000000"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20552, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"2000000000\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
20550 obj->Get(context.local(), v8_str("2000000000"))do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("2000000000"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20552, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"2000000000\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
20551 .ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("2000000000"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20552, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"2000000000\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
20552 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("DONT_CHANGE") ->Equals
(context.local(), obj->Get(context.local(), v8_str("2000000000"
)) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20552, "Check failed: %s.", "v8_str(\"DONT_CHANGE\") ->Equals(context.local(), obj->Get(context.local(), v8_str(\"2000000000\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
20553}
20554
20555
20556static int CountLiveMapsInMapCache(i::Context* context) {
20557 i::FixedArray* map_cache = i::FixedArray::cast(context->map_cache());
20558 int length = map_cache->length();
20559 int count = 0;
20560 for (int i = 0; i < length; i++) {
20561 i::Object* value = map_cache->get(i);
20562 if (value->IsWeakCell() && !i::WeakCell::cast(value)->cleared()) count++;
20563 }
20564 return count;
20565}
20566
20567
20568THREADED_TEST(Regress1516)static void TestRegress1516(); RegisterThreadedTest register_Regress1516
(TestRegress1516, "Regress1516"); static void TestRegress1516
(); CcTest register_test_Regress1516(TestRegress1516, "../test/cctest/test-api.cc"
, "Regress1516", __null, true, true); static void TestRegress1516
()
{
20569 LocalContext context;
20570 v8::HandleScope scope(context->GetIsolate());
20571
20572 // Object with 20 properties is not a common case, so it should be removed
20573 // from the cache after GC.
20574 { v8::HandleScope temp_scope(context->GetIsolate());
20575 CompileRun(
20576 "({"
20577 "'a00': 0, 'a01': 0, 'a02': 0, 'a03': 0, 'a04': 0, "
20578 "'a05': 0, 'a06': 0, 'a07': 0, 'a08': 0, 'a09': 0, "
20579 "'a10': 0, 'a11': 0, 'a12': 0, 'a13': 0, 'a14': 0, "
20580 "'a15': 0, 'a16': 0, 'a17': 0, 'a18': 0, 'a19': 0, "
20581 "})");
20582 }
20583
20584 int elements = CountLiveMapsInMapCache(CcTest::i_isolate()->context());
20585 CHECK_LE(1, elements)do { if (std::string* _msg = ::v8::base::CheckLEImpl( (1), (elements
), "1" " " "<=" " " "elements")) { V8_Fatal("../test/cctest/test-api.cc"
, 20585, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20586
20587 CcTest::heap()->CollectAllGarbage();
20588
20589 CHECK_GT(elements, CountLiveMapsInMapCache(CcTest::i_isolate()->context()))do { if (std::string* _msg = ::v8::base::CheckGTImpl( (elements
), (CountLiveMapsInMapCache(CcTest::i_isolate()->context()
)), "elements" " " ">" " " "CountLiveMapsInMapCache(CcTest::i_isolate()->context())"
)) { V8_Fatal("../test/cctest/test-api.cc", 20589, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20590}
20591
20592
20593THREADED_TEST(Regress93759)static void TestRegress93759(); RegisterThreadedTest register_Regress93759
(TestRegress93759, "Regress93759"); static void TestRegress93759
(); CcTest register_test_Regress93759(TestRegress93759, "../test/cctest/test-api.cc"
, "Regress93759", __null, true, true); static void TestRegress93759
()
{
20594 v8::Isolate* isolate = CcTest::isolate();
20595 HandleScope scope(isolate);
20596
20597 // Template for object with security check.
20598 Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New(isolate);
20599 no_proto_template->SetAccessCheckCallback(AccessAlwaysBlocked);
20600
20601 // Templates for objects with hidden prototypes and possibly security check.
20602 Local<FunctionTemplate> hidden_proto_template =
20603 v8::FunctionTemplate::New(isolate);
20604 hidden_proto_template->SetHiddenPrototype(true);
20605
20606 Local<FunctionTemplate> protected_hidden_proto_template =
20607 v8::FunctionTemplate::New(isolate);
20608 protected_hidden_proto_template->InstanceTemplate()->SetAccessCheckCallback(
20609 AccessAlwaysBlocked);
20610 protected_hidden_proto_template->SetHiddenPrototype(true);
20611
20612 // Context for "foreign" objects used in test.
20613 Local<Context> context = v8::Context::New(isolate);
20614 context->Enter();
20615
20616 // Plain object, no security check.
20617 Local<Object> simple_object = Object::New(isolate);
20618
20619 // Object with explicit security check.
20620 Local<Object> protected_object =
20621 no_proto_template->NewInstance(context).ToLocalChecked();
20622
20623 // JSGlobalProxy object, always have security check.
20624 Local<Object> proxy_object = context->Global();
20625
20626 // Global object, the prototype of proxy_object. No security checks.
20627 Local<Object> global_object =
20628 proxy_object->GetPrototype()->ToObject(context).ToLocalChecked();
20629
20630 // Hidden prototype without security check.
20631 Local<Object> hidden_prototype = hidden_proto_template->GetFunction(context)
20632 .ToLocalChecked()
20633 ->NewInstance(context)
20634 .ToLocalChecked();
20635 Local<Object> object_with_hidden =
20636 Object::New(isolate);
20637 object_with_hidden->SetPrototype(context, hidden_prototype).FromJust();
20638
20639 context->Exit();
20640
20641 LocalContext context2;
20642 v8::Local<v8::Object> global = context2->Global();
20643
20644 // Setup global variables.
20645 CHECK(global->Set(context2.local(), v8_str("simple"), simple_object)do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("simple"), simple_object) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20646, "Check failed: %s.", "global->Set(context2.local(), v8_str(\"simple\"), simple_object) .FromJust()"
); } } while (0)
20646 .FromJust())do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("simple"), simple_object) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20646, "Check failed: %s.", "global->Set(context2.local(), v8_str(\"simple\"), simple_object) .FromJust()"
); } } while (0)
;
20647 CHECK(global->Set(context2.local(), v8_str("protected"), protected_object)do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("protected"), protected_object) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 20648, "Check failed: %s."
, "global->Set(context2.local(), v8_str(\"protected\"), protected_object) .FromJust()"
); } } while (0)
20648 .FromJust())do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("protected"), protected_object) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 20648, "Check failed: %s."
, "global->Set(context2.local(), v8_str(\"protected\"), protected_object) .FromJust()"
); } } while (0)
;
20649 CHECK(global->Set(context2.local(), v8_str("global"), global_object)do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("global"), global_object) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20650, "Check failed: %s.", "global->Set(context2.local(), v8_str(\"global\"), global_object) .FromJust()"
); } } while (0)
20650 .FromJust())do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("global"), global_object) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20650, "Check failed: %s.", "global->Set(context2.local(), v8_str(\"global\"), global_object) .FromJust()"
); } } while (0)
;
20651 CHECK(do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("proxy"), proxy_object).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20652, "Check failed: %s.", "global->Set(context2.local(), v8_str(\"proxy\"), proxy_object).FromJust()"
); } } while (0)
20652 global->Set(context2.local(), v8_str("proxy"), proxy_object).FromJust())do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("proxy"), proxy_object).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20652, "Check failed: %s.", "global->Set(context2.local(), v8_str(\"proxy\"), proxy_object).FromJust()"
); } } while (0)
;
20653 CHECK(global->Set(context2.local(), v8_str("hidden"), object_with_hidden)do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("hidden"), object_with_hidden) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 20654, "Check failed: %s."
, "global->Set(context2.local(), v8_str(\"hidden\"), object_with_hidden) .FromJust()"
); } } while (0)
20654 .FromJust())do { if ((__builtin_expect(!!(!(global->Set(context2.local
(), v8_str("hidden"), object_with_hidden) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 20654, "Check failed: %s."
, "global->Set(context2.local(), v8_str(\"hidden\"), object_with_hidden) .FromJust()"
); } } while (0)
;
20655
20656 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)");
20657 CHECK(result1->Equals(context2.local(), simple_object->GetPrototype())do { if ((__builtin_expect(!!(!(result1->Equals(context2.local
(), simple_object->GetPrototype()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20658, "Check failed: %s.", "result1->Equals(context2.local(), simple_object->GetPrototype()) .FromJust()"
); } } while (0)
20658 .FromJust())do { if ((__builtin_expect(!!(!(result1->Equals(context2.local
(), simple_object->GetPrototype()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20658, "Check failed: %s.", "result1->Equals(context2.local(), simple_object->GetPrototype()) .FromJust()"
); } } while (0)
;
20659
20660 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)");
20661 CHECK(result2->IsNull())do { if ((__builtin_expect(!!(!(result2->IsNull())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 20661, "Check failed: %s."
, "result2->IsNull()"); } } while (0)
;
20662
20663 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)");
20664 CHECK(result3->Equals(context2.local(), global_object->GetPrototype())do { if ((__builtin_expect(!!(!(result3->Equals(context2.local
(), global_object->GetPrototype()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20665, "Check failed: %s.", "result3->Equals(context2.local(), global_object->GetPrototype()) .FromJust()"
); } } while (0)
20665 .FromJust())do { if ((__builtin_expect(!!(!(result3->Equals(context2.local
(), global_object->GetPrototype()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20665, "Check failed: %s.", "result3->Equals(context2.local(), global_object->GetPrototype()) .FromJust()"
); } } while (0)
;
20666
20667 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)");
20668 CHECK(result4->IsNull())do { if ((__builtin_expect(!!(!(result4->IsNull())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 20668, "Check failed: %s."
, "result4->IsNull()"); } } while (0)
;
20669
20670 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)");
20671 CHECK(result5->Equals(context2.local(), object_with_hidden->GetPrototype()do { if ((__builtin_expect(!!(!(result5->Equals(context2.local
(), object_with_hidden->GetPrototype() ->ToObject(context2
.local()) .ToLocalChecked() ->GetPrototype()) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20675, "Check failed: %s."
, "result5->Equals(context2.local(), object_with_hidden->GetPrototype() ->ToObject(context2.local()) .ToLocalChecked() ->GetPrototype()) .FromJust()"
); } } while (0)
20672 ->ToObject(context2.local())do { if ((__builtin_expect(!!(!(result5->Equals(context2.local
(), object_with_hidden->GetPrototype() ->ToObject(context2
.local()) .ToLocalChecked() ->GetPrototype()) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20675, "Check failed: %s."
, "result5->Equals(context2.local(), object_with_hidden->GetPrototype() ->ToObject(context2.local()) .ToLocalChecked() ->GetPrototype()) .FromJust()"
); } } while (0)
20673 .ToLocalChecked()do { if ((__builtin_expect(!!(!(result5->Equals(context2.local
(), object_with_hidden->GetPrototype() ->ToObject(context2
.local()) .ToLocalChecked() ->GetPrototype()) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20675, "Check failed: %s."
, "result5->Equals(context2.local(), object_with_hidden->GetPrototype() ->ToObject(context2.local()) .ToLocalChecked() ->GetPrototype()) .FromJust()"
); } } while (0)
20674 ->GetPrototype())do { if ((__builtin_expect(!!(!(result5->Equals(context2.local
(), object_with_hidden->GetPrototype() ->ToObject(context2
.local()) .ToLocalChecked() ->GetPrototype()) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20675, "Check failed: %s."
, "result5->Equals(context2.local(), object_with_hidden->GetPrototype() ->ToObject(context2.local()) .ToLocalChecked() ->GetPrototype()) .FromJust()"
); } } while (0)
20675 .FromJust())do { if ((__builtin_expect(!!(!(result5->Equals(context2.local
(), object_with_hidden->GetPrototype() ->ToObject(context2
.local()) .ToLocalChecked() ->GetPrototype()) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20675, "Check failed: %s."
, "result5->Equals(context2.local(), object_with_hidden->GetPrototype() ->ToObject(context2.local()) .ToLocalChecked() ->GetPrototype()) .FromJust()"
); } } while (0)
;
20676}
20677
20678
20679static void TestReceiver(Local<Value> expected_result,
20680 Local<Value> expected_receiver,
20681 const char* code) {
20682 Local<Value> result = CompileRun(code);
20683 Local<Context> context = CcTest::isolate()->GetCurrentContext();
20684 CHECK(result->IsObject())do { if ((__builtin_expect(!!(!(result->IsObject())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 20684, "Check failed: %s."
, "result->IsObject()"); } } while (0)
;
20685 CHECK(expected_receiverdo { if ((__builtin_expect(!!(!(expected_receiver ->Equals
(context, result.As<v8::Object>()->Get(context, 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20688, "Check failed: %s.", "expected_receiver ->Equals(context, result.As<v8::Object>()->Get(context, 1).ToLocalChecked()) .FromJust()"
); } } while (0)
20686 ->Equals(context,do { if ((__builtin_expect(!!(!(expected_receiver ->Equals
(context, result.As<v8::Object>()->Get(context, 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20688, "Check failed: %s.", "expected_receiver ->Equals(context, result.As<v8::Object>()->Get(context, 1).ToLocalChecked()) .FromJust()"
); } } while (0)
20687 result.As<v8::Object>()->Get(context, 1).ToLocalChecked())do { if ((__builtin_expect(!!(!(expected_receiver ->Equals
(context, result.As<v8::Object>()->Get(context, 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20688, "Check failed: %s.", "expected_receiver ->Equals(context, result.As<v8::Object>()->Get(context, 1).ToLocalChecked()) .FromJust()"
); } } while (0)
20688 .FromJust())do { if ((__builtin_expect(!!(!(expected_receiver ->Equals
(context, result.As<v8::Object>()->Get(context, 1).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20688, "Check failed: %s.", "expected_receiver ->Equals(context, result.As<v8::Object>()->Get(context, 1).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20689 CHECK(expected_resultdo { if ((__builtin_expect(!!(!(expected_result ->Equals(context
, result.As<v8::Object>()->Get(context, 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20692, "Check failed: %s.", "expected_result ->Equals(context, result.As<v8::Object>()->Get(context, 0).ToLocalChecked()) .FromJust()"
); } } while (0)
20690 ->Equals(context,do { if ((__builtin_expect(!!(!(expected_result ->Equals(context
, result.As<v8::Object>()->Get(context, 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20692, "Check failed: %s.", "expected_result ->Equals(context, result.As<v8::Object>()->Get(context, 0).ToLocalChecked()) .FromJust()"
); } } while (0)
20691 result.As<v8::Object>()->Get(context, 0).ToLocalChecked())do { if ((__builtin_expect(!!(!(expected_result ->Equals(context
, result.As<v8::Object>()->Get(context, 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20692, "Check failed: %s.", "expected_result ->Equals(context, result.As<v8::Object>()->Get(context, 0).ToLocalChecked()) .FromJust()"
); } } while (0)
20692 .FromJust())do { if ((__builtin_expect(!!(!(expected_result ->Equals(context
, result.As<v8::Object>()->Get(context, 0).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20692, "Check failed: %s.", "expected_result ->Equals(context, result.As<v8::Object>()->Get(context, 0).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20693}
20694
20695
20696THREADED_TEST(ForeignFunctionReceiver)static void TestForeignFunctionReceiver(); RegisterThreadedTest
register_ForeignFunctionReceiver(TestForeignFunctionReceiver
, "ForeignFunctionReceiver"); static void TestForeignFunctionReceiver
(); CcTest register_test_ForeignFunctionReceiver(TestForeignFunctionReceiver
, "../test/cctest/test-api.cc", "ForeignFunctionReceiver", __null
, true, true); static void TestForeignFunctionReceiver()
{
20697 v8::Isolate* isolate = CcTest::isolate();
20698 HandleScope scope(isolate);
20699
20700 // Create two contexts with different "id" properties ('i' and 'o').
20701 // Call a function both from its own context and from a the foreign
20702 // context, and see what "this" is bound to (returning both "this"
20703 // and "this.id" for comparison).
20704
20705 Local<Context> foreign_context = v8::Context::New(isolate);
20706 foreign_context->Enter();
20707 Local<Value> foreign_function =
20708 CompileRun("function func() { return { 0: this.id, "
20709 " 1: this, "
20710 " toString: function() { "
20711 " return this[0];"
20712 " }"
20713 " };"
20714 "}"
20715 "var id = 'i';"
20716 "func;");
20717 CHECK(foreign_function->IsFunction())do { if ((__builtin_expect(!!(!(foreign_function->IsFunction
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20717, "Check failed: %s."
, "foreign_function->IsFunction()"); } } while (0)
;
20718 foreign_context->Exit();
20719
20720 LocalContext context;
20721
20722 Local<String> password = v8_str("Password");
20723 // Don't get hit by security checks when accessing foreign_context's
20724 // global receiver (aka. global proxy).
20725 context->SetSecurityToken(password);
20726 foreign_context->SetSecurityToken(password);
20727
20728 Local<String> i = v8_str("i");
20729 Local<String> o = v8_str("o");
20730 Local<String> id = v8_str("id");
20731
20732 CompileRun("function ownfunc() { return { 0: this.id, "
20733 " 1: this, "
20734 " toString: function() { "
20735 " return this[0];"
20736 " }"
20737 " };"
20738 "}"
20739 "var id = 'o';"
20740 "ownfunc");
20741 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func"), foreign_function) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20743, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"func\"), foreign_function) .FromJust()"
); } } while (0)
20742 ->Set(context.local(), v8_str("func"), foreign_function)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func"), foreign_function) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20743, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"func\"), foreign_function) .FromJust()"
); } } while (0)
20743 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("func"), foreign_function) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20743, "Check failed: %s."
, "context->Global() ->Set(context.local(), v8_str(\"func\"), foreign_function) .FromJust()"
); } } while (0)
;
20744
20745 // Sanity check the contexts.
20746 CHECK(do { if ((__builtin_expect(!!(!(i->Equals( context.local()
, foreign_context->Global()->Get(context.local(), id).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20750, "Check failed: %s.", "i->Equals( context.local(), foreign_context->Global()->Get(context.local(), id).ToLocalChecked()) .FromJust()"
); } } while (0)
20747 i->Equals(do { if ((__builtin_expect(!!(!(i->Equals( context.local()
, foreign_context->Global()->Get(context.local(), id).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20750, "Check failed: %s.", "i->Equals( context.local(), foreign_context->Global()->Get(context.local(), id).ToLocalChecked()) .FromJust()"
); } } while (0)
20748 context.local(),do { if ((__builtin_expect(!!(!(i->Equals( context.local()
, foreign_context->Global()->Get(context.local(), id).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20750, "Check failed: %s.", "i->Equals( context.local(), foreign_context->Global()->Get(context.local(), id).ToLocalChecked()) .FromJust()"
); } } while (0)
20749 foreign_context->Global()->Get(context.local(), id).ToLocalChecked())do { if ((__builtin_expect(!!(!(i->Equals( context.local()
, foreign_context->Global()->Get(context.local(), id).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20750, "Check failed: %s.", "i->Equals( context.local(), foreign_context->Global()->Get(context.local(), id).ToLocalChecked()) .FromJust()"
); } } while (0)
20750 .FromJust())do { if ((__builtin_expect(!!(!(i->Equals( context.local()
, foreign_context->Global()->Get(context.local(), id).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20750, "Check failed: %s.", "i->Equals( context.local(), foreign_context->Global()->Get(context.local(), id).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20751 CHECK(o->Equals(context.local(),do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
context->Global()->Get(context.local(), id).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20753, "Check failed: %s.", "o->Equals(context.local(), context->Global()->Get(context.local(), id).ToLocalChecked()) .FromJust()"
); } } while (0)
20752 context->Global()->Get(context.local(), id).ToLocalChecked())do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
context->Global()->Get(context.local(), id).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20753, "Check failed: %s.", "o->Equals(context.local(), context->Global()->Get(context.local(), id).ToLocalChecked()) .FromJust()"
); } } while (0)
20753 .FromJust())do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
context->Global()->Get(context.local(), id).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 20753, "Check failed: %s.", "o->Equals(context.local(), context->Global()->Get(context.local(), id).ToLocalChecked()) .FromJust()"
); } } while (0)
;
20754
20755 // Checking local function's receiver.
20756 // Calling function using its call/apply methods.
20757 TestReceiver(o, context->Global(), "ownfunc.call()");
20758 TestReceiver(o, context->Global(), "ownfunc.apply()");
20759 // Making calls through built-in functions.
20760 TestReceiver(o, context->Global(), "[1].map(ownfunc)[0]");
20761 CHECK(do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/,ownfunc)[1]")) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 20763, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/,ownfunc)[1]\")) .FromJust()"
); } } while (0)
20762 o->Equals(context.local(), CompileRun("'abcbd'.replace(/b/,ownfunc)[1]"))do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/,ownfunc)[1]")) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 20763, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/,ownfunc)[1]\")) .FromJust()"
); } } while (0)
20763 .FromJust())do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/,ownfunc)[1]")) .FromJust()))
, 0))) { V8_Fatal("../test/cctest/test-api.cc", 20763, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/,ownfunc)[1]\")) .FromJust()"
); } } while (0)
;
20764 CHECK(do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,ownfunc)[1]")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20766, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,ownfunc)[1]\")) .FromJust()"
); } } while (0)
20765 o->Equals(context.local(), CompileRun("'abcbd'.replace(/b/g,ownfunc)[1]"))do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,ownfunc)[1]")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20766, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,ownfunc)[1]\")) .FromJust()"
); } } while (0)
20766 .FromJust())do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,ownfunc)[1]")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20766, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,ownfunc)[1]\")) .FromJust()"
); } } while (0)
;
20767 CHECK(do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,ownfunc)[3]")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20769, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,ownfunc)[3]\")) .FromJust()"
); } } while (0)
20768 o->Equals(context.local(), CompileRun("'abcbd'.replace(/b/g,ownfunc)[3]"))do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,ownfunc)[3]")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20769, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,ownfunc)[3]\")) .FromJust()"
); } } while (0)
20769 .FromJust())do { if ((__builtin_expect(!!(!(o->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,ownfunc)[3]")) .FromJust())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 20769, "Check failed: %s."
, "o->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,ownfunc)[3]\")) .FromJust()"
); } } while (0)
;
20770 // Calling with environment record as base.
20771 TestReceiver(o, context->Global(), "ownfunc()");
20772 // Calling with no base.
20773 TestReceiver(o, context->Global(), "(1,ownfunc)()");
20774
20775 // Checking foreign function return value.
20776 // Calling function using its call/apply methods.
20777 TestReceiver(i, foreign_context->Global(), "func.call()");
20778 TestReceiver(i, foreign_context->Global(), "func.apply()");
20779 // Calling function using another context's call/apply methods.
20780 TestReceiver(i, foreign_context->Global(),
20781 "Function.prototype.call.call(func)");
20782 TestReceiver(i, foreign_context->Global(),
20783 "Function.prototype.call.apply(func)");
20784 TestReceiver(i, foreign_context->Global(),
20785 "Function.prototype.apply.call(func)");
20786 TestReceiver(i, foreign_context->Global(),
20787 "Function.prototype.apply.apply(func)");
20788 // Making calls through built-in functions.
20789 TestReceiver(i, foreign_context->Global(), "[1].map(func)[0]");
20790 // ToString(func()) is func()[0], i.e., the returned this.id.
20791 CHECK(i->Equals(context.local(), CompileRun("'abcbd'.replace(/b/,func)[1]"))do { if ((__builtin_expect(!!(!(i->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/,func)[1]")) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 20792, "Check failed: %s."
, "i->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/,func)[1]\")) .FromJust()"
); } } while (0)
20792 .FromJust())do { if ((__builtin_expect(!!(!(i->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/,func)[1]")) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 20792, "Check failed: %s."
, "i->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/,func)[1]\")) .FromJust()"
); } } while (0)
;
20793 CHECK(i->Equals(context.local(), CompileRun("'abcbd'.replace(/b/g,func)[1]"))do { if ((__builtin_expect(!!(!(i->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,func)[1]")) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 20794, "Check failed: %s."
, "i->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,func)[1]\")) .FromJust()"
); } } while (0)
20794 .FromJust())do { if ((__builtin_expect(!!(!(i->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,func)[1]")) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 20794, "Check failed: %s."
, "i->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,func)[1]\")) .FromJust()"
); } } while (0)
;
20795 CHECK(i->Equals(context.local(), CompileRun("'abcbd'.replace(/b/g,func)[3]"))do { if ((__builtin_expect(!!(!(i->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,func)[3]")) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 20796, "Check failed: %s."
, "i->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,func)[3]\")) .FromJust()"
); } } while (0)
20796 .FromJust())do { if ((__builtin_expect(!!(!(i->Equals(context.local(),
CompileRun("'abcbd'.replace(/b/g,func)[3]")) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 20796, "Check failed: %s."
, "i->Equals(context.local(), CompileRun(\"'abcbd'.replace(/b/g,func)[3]\")) .FromJust()"
); } } while (0)
;
20797
20798 // Calling with environment record as base.
20799 TestReceiver(i, foreign_context->Global(), "func()");
20800 // Calling with no base.
20801 TestReceiver(i, foreign_context->Global(), "(1,func)()");
20802}
20803
20804
20805uint8_t callback_fired = 0;
20806uint8_t before_call_entered_callback_count1 = 0;
20807uint8_t before_call_entered_callback_count2 = 0;
20808
20809
20810void CallCompletedCallback1(v8::Isolate*) {
20811 v8::base::OS::Print("Firing callback 1.\n");
20812 callback_fired ^= 1; // Toggle first bit.
20813}
20814
20815
20816void CallCompletedCallback2(v8::Isolate*) {
20817 v8::base::OS::Print("Firing callback 2.\n");
20818 callback_fired ^= 2; // Toggle second bit.
20819}
20820
20821
20822void BeforeCallEnteredCallback1(v8::Isolate*) {
20823 v8::base::OS::Print("Firing before call entered callback 1.\n");
20824 before_call_entered_callback_count1++;
20825}
20826
20827
20828void BeforeCallEnteredCallback2(v8::Isolate*) {
20829 v8::base::OS::Print("Firing before call entered callback 2.\n");
20830 before_call_entered_callback_count2++;
20831}
20832
20833
20834void RecursiveCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
20835 int32_t level =
20836 args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust();
20837 if (level < 3) {
20838 level++;
20839 v8::base::OS::Print("Entering recursion level %d.\n", level);
20840 char script[64];
20841 i::Vector<char> script_vector(script, sizeof(script));
20842 i::SNPrintF(script_vector, "recursion(%d)", level);
20843 CompileRun(script_vector.start());
20844 v8::base::OS::Print("Leaving recursion level %d.\n", level);
20845 CHECK_EQ(0, callback_fired)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (callback_fired
), "0" " " "==" " " "callback_fired")) { V8_Fatal("../test/cctest/test-api.cc"
, 20845, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20846 } else {
20847 v8::base::OS::Print("Recursion ends.\n");
20848 CHECK_EQ(0, callback_fired)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (callback_fired
), "0" " " "==" " " "callback_fired")) { V8_Fatal("../test/cctest/test-api.cc"
, 20848, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20849 }
20850}
20851
20852
20853TEST(CallCompletedCallback)static void TestCallCompletedCallback(); CcTest register_test_CallCompletedCallback
(TestCallCompletedCallback, "../test/cctest/test-api.cc", "CallCompletedCallback"
, __null, true, true); static void TestCallCompletedCallback(
)
{
20854 LocalContext env;
20855 v8::HandleScope scope(env->GetIsolate());
20856 v8::Local<v8::FunctionTemplate> recursive_runtime =
20857 v8::FunctionTemplate::New(env->GetIsolate(), RecursiveCall);
20858 env->Global()
20859 ->Set(env.local(), v8_str("recursion"),
20860 recursive_runtime->GetFunction(env.local()).ToLocalChecked())
20861 .FromJust();
20862 // Adding the same callback a second time has no effect.
20863 env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback1);
20864 env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback1);
20865 env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback2);
20866 env->GetIsolate()->AddBeforeCallEnteredCallback(BeforeCallEnteredCallback1);
20867 env->GetIsolate()->AddBeforeCallEnteredCallback(BeforeCallEnteredCallback2);
20868 env->GetIsolate()->AddBeforeCallEnteredCallback(BeforeCallEnteredCallback1);
20869 v8::base::OS::Print("--- Script (1) ---\n");
20870 callback_fired = 0;
20871 before_call_entered_callback_count1 = 0;
20872 before_call_entered_callback_count2 = 0;
20873 Local<Script> script =
20874 v8::Script::Compile(env.local(), v8_str("recursion(0)")).ToLocalChecked();
20875 script->Run(env.local()).ToLocalChecked();
20876 CHECK_EQ(3, callback_fired)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (callback_fired
), "3" " " "==" " " "callback_fired")) { V8_Fatal("../test/cctest/test-api.cc"
, 20876, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20877 CHECK_EQ(4, before_call_entered_callback_count1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (before_call_entered_callback_count1
), "4" " " "==" " " "before_call_entered_callback_count1")) {
V8_Fatal("../test/cctest/test-api.cc", 20877, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20878 CHECK_EQ(4, before_call_entered_callback_count2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (before_call_entered_callback_count2
), "4" " " "==" " " "before_call_entered_callback_count2")) {
V8_Fatal("../test/cctest/test-api.cc", 20878, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20879
20880 v8::base::OS::Print("\n--- Script (2) ---\n");
20881 callback_fired = 0;
20882 before_call_entered_callback_count1 = 0;
20883 before_call_entered_callback_count2 = 0;
20884 env->GetIsolate()->RemoveCallCompletedCallback(CallCompletedCallback1);
20885 env->GetIsolate()->RemoveBeforeCallEnteredCallback(
20886 BeforeCallEnteredCallback1);
20887 script->Run(env.local()).ToLocalChecked();
20888 CHECK_EQ(2, callback_fired)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (callback_fired
), "2" " " "==" " " "callback_fired")) { V8_Fatal("../test/cctest/test-api.cc"
, 20888, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20889 CHECK_EQ(0, before_call_entered_callback_count1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (before_call_entered_callback_count1
), "0" " " "==" " " "before_call_entered_callback_count1")) {
V8_Fatal("../test/cctest/test-api.cc", 20889, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20890 CHECK_EQ(4, before_call_entered_callback_count2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (before_call_entered_callback_count2
), "4" " " "==" " " "before_call_entered_callback_count2")) {
V8_Fatal("../test/cctest/test-api.cc", 20890, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20891
20892 v8::base::OS::Print("\n--- Function ---\n");
20893 callback_fired = 0;
20894 before_call_entered_callback_count1 = 0;
20895 before_call_entered_callback_count2 = 0;
20896 Local<Function> recursive_function = Local<Function>::Cast(
20897 env->Global()->Get(env.local(), v8_str("recursion")).ToLocalChecked());
20898 v8::Local<Value> args[] = {v8_num(0)};
20899 recursive_function->Call(env.local(), env->Global(), 1, args)
20900 .ToLocalChecked();
20901 CHECK_EQ(2, callback_fired)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (callback_fired
), "2" " " "==" " " "callback_fired")) { V8_Fatal("../test/cctest/test-api.cc"
, 20901, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
20902 CHECK_EQ(0, before_call_entered_callback_count1)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (before_call_entered_callback_count1
), "0" " " "==" " " "before_call_entered_callback_count1")) {
V8_Fatal("../test/cctest/test-api.cc", 20902, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20903 CHECK_EQ(4, before_call_entered_callback_count2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (before_call_entered_callback_count2
), "4" " " "==" " " "before_call_entered_callback_count2")) {
V8_Fatal("../test/cctest/test-api.cc", 20903, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20904}
20905
20906
20907void CallCompletedCallbackNoException(v8::Isolate*) {
20908 v8::HandleScope scope(CcTest::isolate());
20909 CompileRun("1+1;");
20910}
20911
20912
20913void CallCompletedCallbackException(v8::Isolate*) {
20914 v8::HandleScope scope(CcTest::isolate());
20915 CompileRun("throw 'second exception';");
20916}
20917
20918
20919TEST(CallCompletedCallbackOneException)static void TestCallCompletedCallbackOneException(); CcTest register_test_CallCompletedCallbackOneException
(TestCallCompletedCallbackOneException, "../test/cctest/test-api.cc"
, "CallCompletedCallbackOneException", __null, true, true); static
void TestCallCompletedCallbackOneException()
{
20920 LocalContext env;
20921 v8::HandleScope scope(env->GetIsolate());
20922 env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallbackNoException);
20923 CompileRun("throw 'exception';");
20924}
20925
20926
20927TEST(CallCompletedCallbackTwoExceptions)static void TestCallCompletedCallbackTwoExceptions(); CcTest register_test_CallCompletedCallbackTwoExceptions
(TestCallCompletedCallbackTwoExceptions, "../test/cctest/test-api.cc"
, "CallCompletedCallbackTwoExceptions", __null, true, true); static
void TestCallCompletedCallbackTwoExceptions()
{
20928 LocalContext env;
20929 v8::HandleScope scope(env->GetIsolate());
20930 env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallbackException);
20931 CompileRun("throw 'first exception';");
20932}
20933
20934
20935static void MicrotaskOne(const v8::FunctionCallbackInfo<Value>& info) {
20936 v8::HandleScope scope(info.GetIsolate());
20937 CompileRun("ext1Calls++;");
20938}
20939
20940
20941static void MicrotaskTwo(const v8::FunctionCallbackInfo<Value>& info) {
20942 v8::HandleScope scope(info.GetIsolate());
20943 CompileRun("ext2Calls++;");
20944}
20945
20946
20947void* g_passed_to_three = NULL__null;
20948
20949
20950static void MicrotaskThree(void* data) {
20951 g_passed_to_three = data;
20952}
20953
20954
20955TEST(EnqueueMicrotask)static void TestEnqueueMicrotask(); CcTest register_test_EnqueueMicrotask
(TestEnqueueMicrotask, "../test/cctest/test-api.cc", "EnqueueMicrotask"
, __null, true, true); static void TestEnqueueMicrotask()
{
20956 LocalContext env;
20957 v8::HandleScope scope(env->GetIsolate());
20958 CompileRun(
20959 "var ext1Calls = 0;"
20960 "var ext2Calls = 0;");
20961 CompileRun("1+1;");
20962 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "0" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20962, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20963 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "0" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20963, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20964
20965 env->GetIsolate()->EnqueueMicrotask(
20966 Function::New(env.local(), MicrotaskOne).ToLocalChecked());
20967 CompileRun("1+1;");
20968 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "1" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20968, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20969 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "0" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20969, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20970
20971 env->GetIsolate()->EnqueueMicrotask(
20972 Function::New(env.local(), MicrotaskOne).ToLocalChecked());
20973 env->GetIsolate()->EnqueueMicrotask(
20974 Function::New(env.local(), MicrotaskTwo).ToLocalChecked());
20975 CompileRun("1+1;");
20976 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20976, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20977 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "1" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20977, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20978
20979 env->GetIsolate()->EnqueueMicrotask(
20980 Function::New(env.local(), MicrotaskTwo).ToLocalChecked());
20981 CompileRun("1+1;");
20982 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20982, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20983 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20983, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20984
20985 CompileRun("1+1;");
20986 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20986, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20987 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20987, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20988
20989 g_passed_to_three = NULL__null;
20990 env->GetIsolate()->EnqueueMicrotask(MicrotaskThree);
20991 CompileRun("1+1;");
20992 CHECK(!g_passed_to_three)do { if ((__builtin_expect(!!(!(!g_passed_to_three)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 20992, "Check failed: %s.", "!g_passed_to_three"
); } } while (0)
;
20993 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20993, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20994 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 20994, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
20995
20996 int dummy;
20997 env->GetIsolate()->EnqueueMicrotask(
20998 Function::New(env.local(), MicrotaskOne).ToLocalChecked());
20999 env->GetIsolate()->EnqueueMicrotask(MicrotaskThree, &dummy);
21000 env->GetIsolate()->EnqueueMicrotask(
21001 Function::New(env.local(), MicrotaskTwo).ToLocalChecked());
21002 CompileRun("1+1;");
21003 CHECK_EQ(&dummy, g_passed_to_three)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (&dummy
), (g_passed_to_three), "&dummy" " " "==" " " "g_passed_to_three"
)) { V8_Fatal("../test/cctest/test-api.cc", 21003, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21004 CHECK_EQ(3, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "3" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21004, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21005 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "3" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21005, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21006 g_passed_to_three = NULL__null;
21007}
21008
21009
21010static void MicrotaskExceptionOne(
21011 const v8::FunctionCallbackInfo<Value>& info) {
21012 v8::HandleScope scope(info.GetIsolate());
21013 CompileRun("exception1Calls++;");
21014 info.GetIsolate()->ThrowException(
21015 v8::Exception::Error(v8_str("first")));
21016}
21017
21018
21019static void MicrotaskExceptionTwo(
21020 const v8::FunctionCallbackInfo<Value>& info) {
21021 v8::HandleScope scope(info.GetIsolate());
21022 CompileRun("exception2Calls++;");
21023 info.GetIsolate()->ThrowException(
21024 v8::Exception::Error(v8_str("second")));
21025}
21026
21027
21028TEST(RunMicrotasksIgnoresThrownExceptions)static void TestRunMicrotasksIgnoresThrownExceptions(); CcTest
register_test_RunMicrotasksIgnoresThrownExceptions(TestRunMicrotasksIgnoresThrownExceptions
, "../test/cctest/test-api.cc", "RunMicrotasksIgnoresThrownExceptions"
, __null, true, true); static void TestRunMicrotasksIgnoresThrownExceptions
()
{
21029 LocalContext env;
21030 v8::Isolate* isolate = env->GetIsolate();
21031 v8::HandleScope scope(isolate);
21032 CompileRun(
21033 "var exception1Calls = 0;"
21034 "var exception2Calls = 0;");
21035 isolate->EnqueueMicrotask(
21036 Function::New(env.local(), MicrotaskExceptionOne).ToLocalChecked());
21037 isolate->EnqueueMicrotask(
21038 Function::New(env.local(), MicrotaskExceptionTwo).ToLocalChecked());
21039 TryCatch try_catch(isolate);
21040 CompileRun("1+1;");
21041 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 21041, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
21042 CHECK_EQ(1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("exception1Calls")->Int32Value(env.local()).FromJust()), "1"
" " "==" " " "CompileRun(\"exception1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21043, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
21043 CompileRun("exception1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("exception1Calls")->Int32Value(env.local()).FromJust()), "1"
" " "==" " " "CompileRun(\"exception1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21043, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21044 CHECK_EQ(1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("exception2Calls")->Int32Value(env.local()).FromJust()), "1"
" " "==" " " "CompileRun(\"exception2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21045, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
21045 CompileRun("exception2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("exception2Calls")->Int32Value(env.local()).FromJust()), "1"
" " "==" " " "CompileRun(\"exception2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21045, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21046}
21047
21048
21049TEST(SetAutorunMicrotasks)static void TestSetAutorunMicrotasks(); CcTest register_test_SetAutorunMicrotasks
(TestSetAutorunMicrotasks, "../test/cctest/test-api.cc", "SetAutorunMicrotasks"
, __null, true, true); static void TestSetAutorunMicrotasks()
{
21050 LocalContext env;
21051 v8::HandleScope scope(env->GetIsolate());
21052 CompileRun(
21053 "var ext1Calls = 0;"
21054 "var ext2Calls = 0;");
21055 CompileRun("1+1;");
21056 CHECK_EQ(0, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "0" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21056, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21057 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "0" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21057, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21058
21059 env->GetIsolate()->EnqueueMicrotask(
21060 Function::New(env.local(), MicrotaskOne).ToLocalChecked());
21061 CompileRun("1+1;");
21062 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "1" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21063 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "0" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21063, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21064
21065 env->GetIsolate()->SetAutorunMicrotasks(false);
21066 env->GetIsolate()->EnqueueMicrotask(
21067 Function::New(env.local(), MicrotaskOne).ToLocalChecked());
21068 env->GetIsolate()->EnqueueMicrotask(
21069 Function::New(env.local(), MicrotaskTwo).ToLocalChecked());
21070 CompileRun("1+1;");
21071 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "1" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21071, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21072 CHECK_EQ(0, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "0" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21072, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21073
21074 env->GetIsolate()->RunMicrotasks();
21075 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21075, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21076 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "1" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21076, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21077
21078 env->GetIsolate()->EnqueueMicrotask(
21079 Function::New(env.local(), MicrotaskTwo).ToLocalChecked());
21080 CompileRun("1+1;");
21081 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21081, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21082 CHECK_EQ(1, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "1" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21082, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21083
21084 env->GetIsolate()->RunMicrotasks();
21085 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21085, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21086 CHECK_EQ(2, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21086, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21087
21088 env->GetIsolate()->SetAutorunMicrotasks(true);
21089 env->GetIsolate()->EnqueueMicrotask(
21090 Function::New(env.local(), MicrotaskTwo).ToLocalChecked());
21091 CompileRun("1+1;");
21092 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21092, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21093 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "3" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21093, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21094
21095 env->GetIsolate()->EnqueueMicrotask(
21096 Function::New(env.local(), MicrotaskTwo).ToLocalChecked());
21097 {
21098 v8::Isolate::SuppressMicrotaskExecutionScope scope(env->GetIsolate());
21099 CompileRun("1+1;");
21100 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21100, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21101 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "3" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21101, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21102 }
21103
21104 CompileRun("1+1;");
21105 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("ext1Calls")->Int32Value(env.local()).FromJust()), "2" " "
"==" " " "CompileRun(\"ext1Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21105, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21106 CHECK_EQ(4, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (CompileRun
("ext2Calls")->Int32Value(env.local()).FromJust()), "4" " "
"==" " " "CompileRun(\"ext2Calls\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21106, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21107}
21108
21109
21110TEST(RunMicrotasksWithoutEnteringContext)static void TestRunMicrotasksWithoutEnteringContext(); CcTest
register_test_RunMicrotasksWithoutEnteringContext(TestRunMicrotasksWithoutEnteringContext
, "../test/cctest/test-api.cc", "RunMicrotasksWithoutEnteringContext"
, __null, true, true); static void TestRunMicrotasksWithoutEnteringContext
()
{
21111 v8::Isolate* isolate = CcTest::isolate();
21112 HandleScope handle_scope(isolate);
21113 isolate->SetAutorunMicrotasks(false);
21114 Local<Context> context = Context::New(isolate);
21115 {
21116 Context::Scope context_scope(context);
21117 CompileRun("var ext1Calls = 0;");
21118 isolate->EnqueueMicrotask(
21119 Function::New(context, MicrotaskOne).ToLocalChecked());
21120 }
21121 isolate->RunMicrotasks();
21122 {
21123 Context::Scope context_scope(context);
21124 CHECK_EQ(1, CompileRun("ext1Calls")->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("ext1Calls")->Int32Value(context).FromJust()), "1" " " "=="
" " "CompileRun(\"ext1Calls\")->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21124, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21125 }
21126 isolate->SetAutorunMicrotasks(true);
21127}
21128
21129
21130static void DebugEventInObserver(const v8::Debug::EventDetails& event_details) {
21131 v8::DebugEvent event = event_details.GetEvent();
21132 if (event != v8::Break) return;
21133 Local<Object> exec_state = event_details.GetExecutionState();
21134 Local<Context> context = CcTest::isolate()->GetCurrentContext();
21135 Local<Value> break_id =
21136 exec_state->Get(context, v8_str("break_id")).ToLocalChecked();
21137 CompileRun("function f(id) { new FrameDetails(id, 0); }");
21138 Local<Function> fun = Local<Function>::Cast(
21139 CcTest::global()->Get(context, v8_str("f")).ToLocalChecked());
21140 fun->Call(context, CcTest::global(), 1, &break_id).ToLocalChecked();
21141}
21142
21143
21144TEST(Regress385349)static void TestRegress385349(); CcTest register_test_Regress385349
(TestRegress385349, "../test/cctest/test-api.cc", "Regress385349"
, __null, true, true); static void TestRegress385349()
{
21145 i::FLAG_harmony_object_observe = true;
21146 i::FLAG_allow_natives_syntax = true;
21147 v8::Isolate* isolate = CcTest::isolate();
21148 HandleScope handle_scope(isolate);
21149 isolate->SetAutorunMicrotasks(false);
21150 Local<Context> context = Context::New(isolate);
21151 v8::Debug::SetDebugEventListener(isolate, DebugEventInObserver);
21152 {
21153 Context::Scope context_scope(context);
21154 CompileRun("var obj = {};"
21155 "Object.observe(obj, function(changes) { debugger; });"
21156 "obj.a = 0;");
21157 }
21158 isolate->RunMicrotasks();
21159 isolate->SetAutorunMicrotasks(true);
21160 v8::Debug::SetDebugEventListener(isolate, nullptr);
21161}
21162
21163
21164#ifdef ENABLE_DISASSEMBLER1
21165static int probes_counter = 0;
21166static int misses_counter = 0;
21167static int updates_counter = 0;
21168
21169
21170static int* LookupCounter(const char* name) {
21171 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) {
21172 return &probes_counter;
21173 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) {
21174 return &misses_counter;
21175 } else if (strcmp(name, "c:V8.MegamorphicStubCacheUpdates") == 0) {
21176 return &updates_counter;
21177 }
21178 return NULL__null;
21179}
21180
21181
21182static const char* kMegamorphicTestProgram =
21183 "function ClassA() { };"
21184 "function ClassB() { };"
21185 "ClassA.prototype.foo = function() { };"
21186 "ClassB.prototype.foo = function() { };"
21187 "function fooify(obj) { obj.foo(); };"
21188 "var a = new ClassA();"
21189 "var b = new ClassB();"
21190 "for (var i = 0; i < 10000; i++) {"
21191 " fooify(a);"
21192 " fooify(b);"
21193 "}";
21194#endif
21195
21196
21197static void StubCacheHelper(bool primary) {
21198#ifdef ENABLE_DISASSEMBLER1
21199 i::FLAG_native_code_counters = true;
21200 if (primary) {
21201 i::FLAG_test_primary_stub_cache = true;
21202 } else {
21203 i::FLAG_test_secondary_stub_cache = true;
21204 }
21205 i::FLAG_crankshaft = false;
21206 LocalContext env;
21207 env->GetIsolate()->SetCounterFunction(LookupCounter);
21208 v8::HandleScope scope(env->GetIsolate());
21209 int initial_probes = probes_counter;
21210 int initial_misses = misses_counter;
21211 int initial_updates = updates_counter;
21212 CompileRun(kMegamorphicTestProgram);
21213 int probes = probes_counter - initial_probes;
21214 int misses = misses_counter - initial_misses;
21215 int updates = updates_counter - initial_updates;
21216 CHECK_LT(updates, 10)do { if (std::string* _msg = ::v8::base::CheckLTImpl( (updates
), (10), "updates" " " "<" " " "10")) { V8_Fatal("../test/cctest/test-api.cc"
, 21216, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
21217 CHECK_LT(misses, 10)do { if (std::string* _msg = ::v8::base::CheckLTImpl( (misses
), (10), "misses" " " "<" " " "10")) { V8_Fatal("../test/cctest/test-api.cc"
, 21217, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
21218 // TODO(verwaest): Update this test to overflow the degree of polymorphism
21219 // before megamorphism. The number of probes will only work once we teach the
21220 // serializer to embed references to counters in the stubs, given that the
21221 // megamorphic_stub_cache_probes is updated in a snapshot-generated stub.
21222 CHECK_GE(probes, 0)do { if (std::string* _msg = ::v8::base::CheckGEImpl( (probes
), (0), "probes" " " ">=" " " "0")) { V8_Fatal("../test/cctest/test-api.cc"
, 21222, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
21223#endif
21224}
21225
21226
21227TEST(SecondaryStubCache)static void TestSecondaryStubCache(); CcTest register_test_SecondaryStubCache
(TestSecondaryStubCache, "../test/cctest/test-api.cc", "SecondaryStubCache"
, __null, true, true); static void TestSecondaryStubCache()
{
21228 StubCacheHelper(true);
21229}
21230
21231
21232TEST(PrimaryStubCache)static void TestPrimaryStubCache(); CcTest register_test_PrimaryStubCache
(TestPrimaryStubCache, "../test/cctest/test-api.cc", "PrimaryStubCache"
, __null, true, true); static void TestPrimaryStubCache()
{
21233 StubCacheHelper(false);
21234}
21235
21236
21237#ifdef DEBUG1
21238static int cow_arrays_created_runtime = 0;
21239
21240
21241static int* LookupCounterCOWArrays(const char* name) {
21242 if (strcmp(name, "c:V8.COWArraysCreatedRuntime") == 0) {
21243 return &cow_arrays_created_runtime;
21244 }
21245 return NULL__null;
21246}
21247#endif
21248
21249
21250TEST(CheckCOWArraysCreatedRuntimeCounter)static void TestCheckCOWArraysCreatedRuntimeCounter(); CcTest
register_test_CheckCOWArraysCreatedRuntimeCounter(TestCheckCOWArraysCreatedRuntimeCounter
, "../test/cctest/test-api.cc", "CheckCOWArraysCreatedRuntimeCounter"
, __null, true, true); static void TestCheckCOWArraysCreatedRuntimeCounter
()
{
21251#ifdef DEBUG1
21252 i::FLAG_native_code_counters = true;
21253 LocalContext env;
21254 env->GetIsolate()->SetCounterFunction(LookupCounterCOWArrays);
21255 v8::HandleScope scope(env->GetIsolate());
21256 int initial_cow_arrays = cow_arrays_created_runtime;
21257 CompileRun("var o = [1, 2, 3];");
21258 CHECK_EQ(1, cow_arrays_created_runtime - initial_cow_arrays)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (cow_arrays_created_runtime
- initial_cow_arrays), "1" " " "==" " " "cow_arrays_created_runtime - initial_cow_arrays"
)) { V8_Fatal("../test/cctest/test-api.cc", 21258, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21259 CompileRun("var o = {foo: [4, 5, 6], bar: [3, 0]};");
21260 CHECK_EQ(3, cow_arrays_created_runtime - initial_cow_arrays)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (cow_arrays_created_runtime
- initial_cow_arrays), "3" " " "==" " " "cow_arrays_created_runtime - initial_cow_arrays"
)) { V8_Fatal("../test/cctest/test-api.cc", 21260, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21261 CompileRun("var o = {foo: [1, 2, 3, [4, 5, 6]], bar: 'hi'};");
21262 CHECK_EQ(4, cow_arrays_created_runtime - initial_cow_arrays)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (cow_arrays_created_runtime
- initial_cow_arrays), "4" " " "==" " " "cow_arrays_created_runtime - initial_cow_arrays"
)) { V8_Fatal("../test/cctest/test-api.cc", 21262, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21263#endif
21264}
21265
21266
21267TEST(StaticGetters)static void TestStaticGetters(); CcTest register_test_StaticGetters
(TestStaticGetters, "../test/cctest/test-api.cc", "StaticGetters"
, __null, true, true); static void TestStaticGetters()
{
21268 LocalContext context;
21269 i::Factory* factory = CcTest::i_isolate()->factory();
21270 v8::Isolate* isolate = CcTest::isolate();
21271 v8::HandleScope scope(isolate);
21272 i::Handle<i::Object> undefined_value = factory->undefined_value();
21273 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value)do { if ((__builtin_expect(!!(!(*v8::Utils::OpenHandle(*v8::Undefined
(isolate)) == *undefined_value)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21273, "Check failed: %s.", "*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value"
); } } while (0)
;
21274 i::Handle<i::Object> null_value = factory->null_value();
21275 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value)do { if ((__builtin_expect(!!(!(*v8::Utils::OpenHandle(*v8::Null
(isolate)) == *null_value)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21275, "Check failed: %s.", "*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value"
); } } while (0)
;
21276 i::Handle<i::Object> true_value = factory->true_value();
21277 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value)do { if ((__builtin_expect(!!(!(*v8::Utils::OpenHandle(*v8::True
(isolate)) == *true_value)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21277, "Check failed: %s.", "*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value"
); } } while (0)
;
21278 i::Handle<i::Object> false_value = factory->false_value();
21279 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value)do { if ((__builtin_expect(!!(!(*v8::Utils::OpenHandle(*v8::False
(isolate)) == *false_value)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21279, "Check failed: %s.", "*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value"
); } } while (0)
;
21280}
21281
21282
21283UNINITIALIZED_TEST(IsolateEmbedderData)static void TestIsolateEmbedderData(); CcTest register_test_IsolateEmbedderData
(TestIsolateEmbedderData, "../test/cctest/test-api.cc", "IsolateEmbedderData"
, __null, true, false); static void TestIsolateEmbedderData()
{
21284 CcTest::DisableAutomaticDispose();
21285 v8::Isolate::CreateParams create_params;
21286 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
21287 v8::Isolate* isolate = v8::Isolate::New(create_params);
21288 isolate->Enter();
21289 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
21290 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) {
21291 CHECK(!isolate->GetData(slot))do { if ((__builtin_expect(!!(!(!isolate->GetData(slot))),
0))) { V8_Fatal("../test/cctest/test-api.cc", 21291, "Check failed: %s."
, "!isolate->GetData(slot)"); } } while (0)
;
21292 CHECK(!i_isolate->GetData(slot))do { if ((__builtin_expect(!!(!(!i_isolate->GetData(slot))
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21292, "Check failed: %s."
, "!i_isolate->GetData(slot)"); } } while (0)
;
21293 }
21294 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) {
21295 void* data = reinterpret_cast<void*>(0xacce55ed + slot);
21296 isolate->SetData(slot, data);
21297 }
21298 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) {
21299 void* data = reinterpret_cast<void*>(0xacce55ed + slot);
21300 CHECK_EQ(data, isolate->GetData(slot))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (data),
(isolate->GetData(slot)), "data" " " "==" " " "isolate->GetData(slot)"
)) { V8_Fatal("../test/cctest/test-api.cc", 21300, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21301 CHECK_EQ(data, i_isolate->GetData(slot))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (data),
(i_isolate->GetData(slot)), "data" " " "==" " " "i_isolate->GetData(slot)"
)) { V8_Fatal("../test/cctest/test-api.cc", 21301, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21302 }
21303 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) {
21304 void* data = reinterpret_cast<void*>(0xdecea5ed + slot);
21305 isolate->SetData(slot, data);
21306 }
21307 for (uint32_t slot = 0; slot < v8::Isolate::GetNumberOfDataSlots(); ++slot) {
21308 void* data = reinterpret_cast<void*>(0xdecea5ed + slot);
21309 CHECK_EQ(data, isolate->GetData(slot))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (data),
(isolate->GetData(slot)), "data" " " "==" " " "isolate->GetData(slot)"
)) { V8_Fatal("../test/cctest/test-api.cc", 21309, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21310 CHECK_EQ(data, i_isolate->GetData(slot))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (data),
(i_isolate->GetData(slot)), "data" " " "==" " " "i_isolate->GetData(slot)"
)) { V8_Fatal("../test/cctest/test-api.cc", 21310, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21311 }
21312 isolate->Exit();
21313 isolate->Dispose();
21314}
21315
21316
21317TEST(StringEmpty)static void TestStringEmpty(); CcTest register_test_StringEmpty
(TestStringEmpty, "../test/cctest/test-api.cc", "StringEmpty"
, __null, true, true); static void TestStringEmpty()
{
21318 LocalContext context;
21319 i::Factory* factory = CcTest::i_isolate()->factory();
21320 v8::Isolate* isolate = CcTest::isolate();
21321 v8::HandleScope scope(isolate);
21322 i::Handle<i::Object> empty_string = factory->empty_string();
21323 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string)do { if ((__builtin_expect(!!(!(*v8::Utils::OpenHandle(*v8::String
::Empty(isolate)) == *empty_string)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21323, "Check failed: %s.", "*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string"
); } } while (0)
;
21324}
21325
21326
21327static int instance_checked_getter_count = 0;
21328static void InstanceCheckedGetter(
21329 Local<String> name,
21330 const v8::PropertyCallbackInfo<v8::Value>& info) {
21331 CHECK(name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("foo"))do { if ((__builtin_expect(!!(!(name->Equals(info.GetIsolate
()->GetCurrentContext(), v8_str("foo")) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 21332, "Check failed: %s."
, "name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"foo\")) .FromJust()"
); } } while (0)
21332 .FromJust())do { if ((__builtin_expect(!!(!(name->Equals(info.GetIsolate
()->GetCurrentContext(), v8_str("foo")) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 21332, "Check failed: %s."
, "name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"foo\")) .FromJust()"
); } } while (0)
;
21333 instance_checked_getter_count++;
21334 info.GetReturnValue().Set(v8_num(11));
21335}
21336
21337
21338static int instance_checked_setter_count = 0;
21339static void InstanceCheckedSetter(Local<String> name,
21340 Local<Value> value,
21341 const v8::PropertyCallbackInfo<void>& info) {
21342 CHECK(name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str("foo"))do { if ((__builtin_expect(!!(!(name->Equals(info.GetIsolate
()->GetCurrentContext(), v8_str("foo")) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 21343, "Check failed: %s."
, "name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"foo\")) .FromJust()"
); } } while (0)
21343 .FromJust())do { if ((__builtin_expect(!!(!(name->Equals(info.GetIsolate
()->GetCurrentContext(), v8_str("foo")) .FromJust())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 21343, "Check failed: %s."
, "name->Equals(info.GetIsolate()->GetCurrentContext(), v8_str(\"foo\")) .FromJust()"
); } } while (0)
;
21344 CHECK(value->Equals(info.GetIsolate()->GetCurrentContext(), v8_num(23))do { if ((__builtin_expect(!!(!(value->Equals(info.GetIsolate
()->GetCurrentContext(), v8_num(23)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 21345, "Check failed: %s."
, "value->Equals(info.GetIsolate()->GetCurrentContext(), v8_num(23)) .FromJust()"
); } } while (0)
21345 .FromJust())do { if ((__builtin_expect(!!(!(value->Equals(info.GetIsolate
()->GetCurrentContext(), v8_num(23)) .FromJust())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 21345, "Check failed: %s."
, "value->Equals(info.GetIsolate()->GetCurrentContext(), v8_num(23)) .FromJust()"
); } } while (0)
;
21346 instance_checked_setter_count++;
21347}
21348
21349
21350static void CheckInstanceCheckedResult(int getters, int setters,
21351 bool expects_callbacks,
21352 TryCatch* try_catch) {
21353 if (expects_callbacks) {
21354 CHECK(!try_catch->HasCaught())do { if ((__builtin_expect(!!(!(!try_catch->HasCaught())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 21354, "Check failed: %s."
, "!try_catch->HasCaught()"); } } while (0)
;
21355 CHECK_EQ(getters, instance_checked_getter_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (getters
), (instance_checked_getter_count), "getters" " " "==" " " "instance_checked_getter_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 21355, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21356 CHECK_EQ(setters, instance_checked_setter_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (setters
), (instance_checked_setter_count), "setters" " " "==" " " "instance_checked_setter_count"
)) { V8_Fatal("../test/cctest/test-api.cc", 21356, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21357 } else {
21358 CHECK(try_catch->HasCaught())do { if ((__builtin_expect(!!(!(try_catch->HasCaught())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 21358, "Check failed: %s."
, "try_catch->HasCaught()"); } } while (0)
;
21359 CHECK_EQ(0, instance_checked_getter_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (instance_checked_getter_count
), "0" " " "==" " " "instance_checked_getter_count")) { V8_Fatal
("../test/cctest/test-api.cc", 21359, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
21360 CHECK_EQ(0, instance_checked_setter_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (instance_checked_setter_count
), "0" " " "==" " " "instance_checked_setter_count")) { V8_Fatal
("../test/cctest/test-api.cc", 21360, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
21361 }
21362 try_catch->Reset();
21363}
21364
21365
21366static void CheckInstanceCheckedAccessors(bool expects_callbacks) {
21367 instance_checked_getter_count = 0;
21368 instance_checked_setter_count = 0;
21369 TryCatch try_catch(CcTest::isolate());
21370
21371 // Test path through generic runtime code.
21372 CompileRun("obj.foo");
21373 CheckInstanceCheckedResult(1, 0, expects_callbacks, &try_catch);
21374 CompileRun("obj.foo = 23");
21375 CheckInstanceCheckedResult(1, 1, expects_callbacks, &try_catch);
21376
21377 // Test path through generated LoadIC and StoredIC.
21378 CompileRun("function test_get(o) { o.foo; }"
21379 "test_get(obj);");
21380 CheckInstanceCheckedResult(2, 1, expects_callbacks, &try_catch);
21381 CompileRun("test_get(obj);");
21382 CheckInstanceCheckedResult(3, 1, expects_callbacks, &try_catch);
21383 CompileRun("test_get(obj);");
21384 CheckInstanceCheckedResult(4, 1, expects_callbacks, &try_catch);
21385 CompileRun("function test_set(o) { o.foo = 23; }"
21386 "test_set(obj);");
21387 CheckInstanceCheckedResult(4, 2, expects_callbacks, &try_catch);
21388 CompileRun("test_set(obj);");
21389 CheckInstanceCheckedResult(4, 3, expects_callbacks, &try_catch);
21390 CompileRun("test_set(obj);");
21391 CheckInstanceCheckedResult(4, 4, expects_callbacks, &try_catch);
21392
21393 // Test path through optimized code.
21394 CompileRun("%OptimizeFunctionOnNextCall(test_get);"
21395 "test_get(obj);");
21396 CheckInstanceCheckedResult(5, 4, expects_callbacks, &try_catch);
21397 CompileRun("%OptimizeFunctionOnNextCall(test_set);"
21398 "test_set(obj);");
21399 CheckInstanceCheckedResult(5, 5, expects_callbacks, &try_catch);
21400
21401 // Cleanup so that closures start out fresh in next check.
21402 CompileRun("%DeoptimizeFunction(test_get);"
21403 "%ClearFunctionTypeFeedback(test_get);"
21404 "%DeoptimizeFunction(test_set);"
21405 "%ClearFunctionTypeFeedback(test_set);");
21406}
21407
21408
21409THREADED_TEST(InstanceCheckOnInstanceAccessor)static void TestInstanceCheckOnInstanceAccessor(); RegisterThreadedTest
register_InstanceCheckOnInstanceAccessor(TestInstanceCheckOnInstanceAccessor
, "InstanceCheckOnInstanceAccessor"); static void TestInstanceCheckOnInstanceAccessor
(); CcTest register_test_InstanceCheckOnInstanceAccessor(TestInstanceCheckOnInstanceAccessor
, "../test/cctest/test-api.cc", "InstanceCheckOnInstanceAccessor"
, __null, true, true); static void TestInstanceCheckOnInstanceAccessor
()
{
21410 v8::internal::FLAG_allow_natives_syntax = true;
21411 LocalContext context;
21412 v8::HandleScope scope(context->GetIsolate());
21413
21414 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
21415 Local<ObjectTemplate> inst = templ->InstanceTemplate();
21416 inst->SetAccessor(v8_str("foo"), InstanceCheckedGetter, InstanceCheckedSetter,
21417 Local<Value>(), v8::DEFAULT, v8::None,
21418 v8::AccessorSignature::New(context->GetIsolate(), templ));
21419 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21422, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21420 ->Set(context.local(), v8_str("f"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21422, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21421 templ->GetFunction(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21422, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21422 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21422, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
21423
21424 printf("Testing positive ...\n");
21425 CompileRun("var obj = new f();");
21426 CHECK(templ->HasInstance(do { if ((__builtin_expect(!!(!(templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21427, "Check failed: %s."
, "templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
21427 context->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked()))do { if ((__builtin_expect(!!(!(templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21427, "Check failed: %s."
, "templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
;
21428 CheckInstanceCheckedAccessors(true);
21429
21430 printf("Testing negative ...\n");
21431 CompileRun("var obj = {};"
21432 "obj.__proto__ = new f();");
21433 CHECK(!templ->HasInstance(do { if ((__builtin_expect(!!(!(!templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21434, "Check failed: %s."
, "!templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
21434 context->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked()))do { if ((__builtin_expect(!!(!(!templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21434, "Check failed: %s."
, "!templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
;
21435 CheckInstanceCheckedAccessors(false);
21436}
21437
21438
21439static void EmptyInterceptorGetter(
21440 Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) {}
21441
21442
21443static void EmptyInterceptorSetter(
21444 Local<String> name, Local<Value> value,
21445 const v8::PropertyCallbackInfo<v8::Value>& info) {}
21446
21447
21448THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor)static void TestInstanceCheckOnInstanceAccessorWithInterceptor
(); RegisterThreadedTest register_InstanceCheckOnInstanceAccessorWithInterceptor
(TestInstanceCheckOnInstanceAccessorWithInterceptor, "InstanceCheckOnInstanceAccessorWithInterceptor"
); static void TestInstanceCheckOnInstanceAccessorWithInterceptor
(); CcTest register_test_InstanceCheckOnInstanceAccessorWithInterceptor
(TestInstanceCheckOnInstanceAccessorWithInterceptor, "../test/cctest/test-api.cc"
, "InstanceCheckOnInstanceAccessorWithInterceptor", __null, true
, true); static void TestInstanceCheckOnInstanceAccessorWithInterceptor
()
{
21449 v8::internal::FLAG_allow_natives_syntax = true;
21450 LocalContext context;
21451 v8::HandleScope scope(context->GetIsolate());
21452
21453 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
21454 Local<ObjectTemplate> inst = templ->InstanceTemplate();
21455 templ->InstanceTemplate()->SetNamedPropertyHandler(EmptyInterceptorGetter,
21456 EmptyInterceptorSetter);
21457 inst->SetAccessor(v8_str("foo"), InstanceCheckedGetter, InstanceCheckedSetter,
21458 Local<Value>(), v8::DEFAULT, v8::None,
21459 v8::AccessorSignature::New(context->GetIsolate(), templ));
21460 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21463, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21461 ->Set(context.local(), v8_str("f"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21463, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21462 templ->GetFunction(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21463, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21463 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21463, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
21464
21465 printf("Testing positive ...\n");
21466 CompileRun("var obj = new f();");
21467 CHECK(templ->HasInstance(do { if ((__builtin_expect(!!(!(templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21468, "Check failed: %s."
, "templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
21468 context->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked()))do { if ((__builtin_expect(!!(!(templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21468, "Check failed: %s."
, "templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
;
21469 CheckInstanceCheckedAccessors(true);
21470
21471 printf("Testing negative ...\n");
21472 CompileRun("var obj = {};"
21473 "obj.__proto__ = new f();");
21474 CHECK(!templ->HasInstance(do { if ((__builtin_expect(!!(!(!templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21475, "Check failed: %s."
, "!templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
21475 context->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked()))do { if ((__builtin_expect(!!(!(!templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21475, "Check failed: %s."
, "!templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
;
21476 CheckInstanceCheckedAccessors(false);
21477}
21478
21479
21480THREADED_TEST(InstanceCheckOnPrototypeAccessor)static void TestInstanceCheckOnPrototypeAccessor(); RegisterThreadedTest
register_InstanceCheckOnPrototypeAccessor(TestInstanceCheckOnPrototypeAccessor
, "InstanceCheckOnPrototypeAccessor"); static void TestInstanceCheckOnPrototypeAccessor
(); CcTest register_test_InstanceCheckOnPrototypeAccessor(TestInstanceCheckOnPrototypeAccessor
, "../test/cctest/test-api.cc", "InstanceCheckOnPrototypeAccessor"
, __null, true, true); static void TestInstanceCheckOnPrototypeAccessor
()
{
21481 v8::internal::FLAG_allow_natives_syntax = true;
21482 LocalContext context;
21483 v8::HandleScope scope(context->GetIsolate());
21484
21485 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
21486 Local<ObjectTemplate> proto = templ->PrototypeTemplate();
21487 proto->SetAccessor(v8_str("foo"), InstanceCheckedGetter,
21488 InstanceCheckedSetter, Local<Value>(), v8::DEFAULT,
21489 v8::None,
21490 v8::AccessorSignature::New(context->GetIsolate(), templ));
21491 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21494, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21492 ->Set(context.local(), v8_str("f"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21494, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21493 templ->GetFunction(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21494, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21494 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("f"), templ->GetFunction(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21494, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"f\"), templ->GetFunction(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
21495
21496 printf("Testing positive ...\n");
21497 CompileRun("var obj = new f();");
21498 CHECK(templ->HasInstance(do { if ((__builtin_expect(!!(!(templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21499, "Check failed: %s."
, "templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
21499 context->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked()))do { if ((__builtin_expect(!!(!(templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21499, "Check failed: %s."
, "templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
;
21500 CheckInstanceCheckedAccessors(true);
21501
21502 printf("Testing negative ...\n");
21503 CompileRun("var obj = {};"
21504 "obj.__proto__ = new f();");
21505 CHECK(!templ->HasInstance(do { if ((__builtin_expect(!!(!(!templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21506, "Check failed: %s."
, "!templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
21506 context->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked()))do { if ((__builtin_expect(!!(!(!templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21506, "Check failed: %s."
, "!templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
;
21507 CheckInstanceCheckedAccessors(false);
21508
21509 printf("Testing positive with modified prototype chain ...\n");
21510 CompileRun("var obj = new f();"
21511 "var pro = {};"
21512 "pro.__proto__ = obj.__proto__;"
21513 "obj.__proto__ = pro;");
21514 CHECK(templ->HasInstance(do { if ((__builtin_expect(!!(!(templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21515, "Check failed: %s."
, "templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
21515 context->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked()))do { if ((__builtin_expect(!!(!(templ->HasInstance( context
->Global()->Get(context.local(), v8_str("obj")).ToLocalChecked
()))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21515, "Check failed: %s."
, "templ->HasInstance( context->Global()->Get(context.local(), v8_str(\"obj\")).ToLocalChecked())"
); } } while (0)
;
21516 CheckInstanceCheckedAccessors(true);
21517}
21518
21519
21520TEST(TryFinallyMessage)static void TestTryFinallyMessage(); CcTest register_test_TryFinallyMessage
(TestTryFinallyMessage, "../test/cctest/test-api.cc", "TryFinallyMessage"
, __null, true, true); static void TestTryFinallyMessage()
{
21521 LocalContext context;
21522 v8::HandleScope scope(context->GetIsolate());
21523 {
21524 // Test that the original error message is not lost if there is a
21525 // recursive call into Javascript is done in the finally block, e.g. to
21526 // initialize an IC. (crbug.com/129171)
21527 TryCatch try_catch(context->GetIsolate());
21528 const char* trigger_ic =
21529 "try { \n"
21530 " throw new Error('test'); \n"
21531 "} finally { \n"
21532 " var x = 0; \n"
21533 " x++; \n" // Trigger an IC initialization here.
21534 "} \n";
21535 CompileRun(trigger_ic);
21536 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 21536, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
21537 Local<Message> message = try_catch.Message();
21538 CHECK(!message.IsEmpty())do { if ((__builtin_expect(!!(!(!message.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21538, "Check failed: %s.", "!message.IsEmpty()"
); } } while (0)
;
21539 CHECK_EQ(2, message->GetLineNumber(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (message
->GetLineNumber(context.local()).FromJust()), "2" " " "=="
" " "message->GetLineNumber(context.local()).FromJust()")
) { V8_Fatal("../test/cctest/test-api.cc", 21539, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21540 }
21541
21542 {
21543 // Test that the original exception message is indeed overwritten if
21544 // a new error is thrown in the finally block.
21545 TryCatch try_catch(context->GetIsolate());
21546 const char* throw_again =
21547 "try { \n"
21548 " throw new Error('test'); \n"
21549 "} finally { \n"
21550 " var x = 0; \n"
21551 " x++; \n"
21552 " throw new Error('again'); \n" // This is the new uncaught error.
21553 "} \n";
21554 CompileRun(throw_again);
21555 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 21555, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
21556 Local<Message> message = try_catch.Message();
21557 CHECK(!message.IsEmpty())do { if ((__builtin_expect(!!(!(!message.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21557, "Check failed: %s.", "!message.IsEmpty()"
); } } while (0)
;
21558 CHECK_EQ(6, message->GetLineNumber(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (6), (message
->GetLineNumber(context.local()).FromJust()), "6" " " "=="
" " "message->GetLineNumber(context.local()).FromJust()")
) { V8_Fatal("../test/cctest/test-api.cc", 21558, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21559 }
21560}
21561
21562
21563static void Helper137002(bool do_store,
21564 bool polymorphic,
21565 bool remove_accessor,
21566 bool interceptor) {
21567 LocalContext context;
21568 Local<ObjectTemplate> templ = ObjectTemplate::New(context->GetIsolate());
21569 if (interceptor) {
21570 templ->SetHandler(v8::NamedPropertyHandlerConfiguration(FooGetInterceptor,
21571 FooSetInterceptor));
21572 } else {
21573 templ->SetAccessor(v8_str("foo"),
21574 GetterWhichReturns42,
21575 SetterWhichSetsYOnThisTo23);
21576 }
21577 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21580, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21578 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21580, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21579 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21580, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21580 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21580, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
21581
21582 // Turn monomorphic on slow object with native accessor, then turn
21583 // polymorphic, finally optimize to create negative lookup and fail.
21584 CompileRun(do_store ?
21585 "function f(x) { x.foo = void 0; }" :
21586 "function f(x) { return x.foo; }");
21587 CompileRun("obj.y = void 0;");
21588 if (!interceptor) {
21589 CompileRun("%OptimizeObjectForAddingMultipleProperties(obj, 1);");
21590 }
21591 CompileRun("obj.__proto__ = null;"
21592 "f(obj); f(obj); f(obj);");
21593 if (polymorphic) {
21594 CompileRun("f({});");
21595 }
21596 CompileRun("obj.y = void 0;"
21597 "%OptimizeFunctionOnNextCall(f);");
21598 if (remove_accessor) {
21599 CompileRun("delete obj.foo;");
21600 }
21601 CompileRun("var result = f(obj);");
21602 if (do_store) {
21603 CompileRun("result = obj.y;");
21604 }
21605 if (remove_accessor && !interceptor) {
21606 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("result")) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21609, "Check failed: %s."
, "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21607 ->Get(context.local(), v8_str("result"))do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("result")) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21609, "Check failed: %s."
, "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21608 .ToLocalChecked()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("result")) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21609, "Check failed: %s."
, "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21609 ->IsUndefined())do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("result")) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21609, "Check failed: %s."
, "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
21610 } else {
21611 CHECK_EQ(do_store ? 23 : 42, context->Global()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (do_store
? 23 : 42), (context->Global() ->Get(context.local(), v8_str
("result")) .ToLocalChecked() ->Int32Value(context.local()
) .FromJust()), "do_store ? 23 : 42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21615, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
21612 ->Get(context.local(), v8_str("result"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (do_store
? 23 : 42), (context->Global() ->Get(context.local(), v8_str
("result")) .ToLocalChecked() ->Int32Value(context.local()
) .FromJust()), "do_store ? 23 : 42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21615, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
21613 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (do_store
? 23 : 42), (context->Global() ->Get(context.local(), v8_str
("result")) .ToLocalChecked() ->Int32Value(context.local()
) .FromJust()), "do_store ? 23 : 42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21615, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
21614 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (do_store
? 23 : 42), (context->Global() ->Get(context.local(), v8_str
("result")) .ToLocalChecked() ->Int32Value(context.local()
) .FromJust()), "do_store ? 23 : 42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21615, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
21615 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (do_store
? 23 : 42), (context->Global() ->Get(context.local(), v8_str
("result")) .ToLocalChecked() ->Int32Value(context.local()
) .FromJust()), "do_store ? 23 : 42" " " "==" " " "context->Global() ->Get(context.local(), v8_str(\"result\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21615, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21616 }
21617}
21618
21619
21620THREADED_TEST(Regress137002a)static void TestRegress137002a(); RegisterThreadedTest register_Regress137002a
(TestRegress137002a, "Regress137002a"); static void TestRegress137002a
(); CcTest register_test_Regress137002a(TestRegress137002a, "../test/cctest/test-api.cc"
, "Regress137002a", __null, true, true); static void TestRegress137002a
()
{
21621 i::FLAG_allow_natives_syntax = true;
21622 i::FLAG_compilation_cache = false;
21623 v8::HandleScope scope(CcTest::isolate());
21624 for (int i = 0; i < 16; i++) {
21625 Helper137002(i & 8, i & 4, i & 2, i & 1);
21626 }
21627}
21628
21629
21630THREADED_TEST(Regress137002b)static void TestRegress137002b(); RegisterThreadedTest register_Regress137002b
(TestRegress137002b, "Regress137002b"); static void TestRegress137002b
(); CcTest register_test_Regress137002b(TestRegress137002b, "../test/cctest/test-api.cc"
, "Regress137002b", __null, true, true); static void TestRegress137002b
()
{
21631 i::FLAG_allow_natives_syntax = true;
21632 LocalContext context;
21633 v8::Isolate* isolate = context->GetIsolate();
21634 v8::HandleScope scope(isolate);
21635 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
21636 templ->SetAccessor(v8_str("foo"),
21637 GetterWhichReturns42,
21638 SetterWhichSetsYOnThisTo23);
21639 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21642, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21640 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21642, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21641 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21642, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21642 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21642, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
21643
21644 // Turn monomorphic on slow object with native accessor, then just
21645 // delete the property and fail.
21646 CompileRun("function load(x) { return x.foo; }"
21647 "function store(x) { x.foo = void 0; }"
21648 "function keyed_load(x, key) { return x[key]; }"
21649 // Second version of function has a different source (add void 0)
21650 // so that it does not share code with the first version. This
21651 // ensures that the ICs are monomorphic.
21652 "function load2(x) { void 0; return x.foo; }"
21653 "function store2(x) { void 0; x.foo = void 0; }"
21654 "function keyed_load2(x, key) { void 0; return x[key]; }"
21655
21656 "obj.y = void 0;"
21657 "obj.__proto__ = null;"
21658 "var subobj = {};"
21659 "subobj.y = void 0;"
21660 "subobj.__proto__ = obj;"
21661 "%OptimizeObjectForAddingMultipleProperties(obj, 1);"
21662
21663 // Make the ICs monomorphic.
21664 "load(obj); load(obj);"
21665 "load2(subobj); load2(subobj);"
21666 "store(obj); store(obj);"
21667 "store2(subobj); store2(subobj);"
21668 "keyed_load(obj, 'foo'); keyed_load(obj, 'foo');"
21669 "keyed_load2(subobj, 'foo'); keyed_load2(subobj, 'foo');"
21670
21671 // Actually test the shiny new ICs and better not crash. This
21672 // serves as a regression test for issue 142088 as well.
21673 "load(obj);"
21674 "load2(subobj);"
21675 "store(obj);"
21676 "store2(subobj);"
21677 "keyed_load(obj, 'foo');"
21678 "keyed_load2(subobj, 'foo');"
21679
21680 // Delete the accessor. It better not be called any more now.
21681 "delete obj.foo;"
21682 "obj.y = void 0;"
21683 "subobj.y = void 0;"
21684
21685 "var load_result = load(obj);"
21686 "var load_result2 = load2(subobj);"
21687 "var keyed_load_result = keyed_load(obj, 'foo');"
21688 "var keyed_load_result2 = keyed_load2(subobj, 'foo');"
21689 "store(obj);"
21690 "store2(subobj);"
21691 "var y_from_obj = obj.y;"
21692 "var y_from_subobj = subobj.y;");
21693 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("load_result")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21696, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"load_result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21694 ->Get(context.local(), v8_str("load_result"))do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("load_result")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21696, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"load_result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21695 .ToLocalChecked()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("load_result")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21696, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"load_result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21696 ->IsUndefined())do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("load_result")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21696, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"load_result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
21697 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("load_result2")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21700, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"load_result2\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21698 ->Get(context.local(), v8_str("load_result2"))do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("load_result2")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21700, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"load_result2\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21699 .ToLocalChecked()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("load_result2")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21700, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"load_result2\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21700 ->IsUndefined())do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("load_result2")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21700, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"load_result2\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
21701 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("keyed_load_result")) .ToLocalChecked
() ->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21704, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"keyed_load_result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21702 ->Get(context.local(), v8_str("keyed_load_result"))do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("keyed_load_result")) .ToLocalChecked
() ->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21704, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"keyed_load_result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21703 .ToLocalChecked()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("keyed_load_result")) .ToLocalChecked
() ->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21704, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"keyed_load_result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21704 ->IsUndefined())do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("keyed_load_result")) .ToLocalChecked
() ->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21704, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"keyed_load_result\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
21705 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("keyed_load_result2")) .ToLocalChecked
() ->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21708, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"keyed_load_result2\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21706 ->Get(context.local(), v8_str("keyed_load_result2"))do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("keyed_load_result2")) .ToLocalChecked
() ->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21708, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"keyed_load_result2\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21707 .ToLocalChecked()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("keyed_load_result2")) .ToLocalChecked
() ->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21708, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"keyed_load_result2\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21708 ->IsUndefined())do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("keyed_load_result2")) .ToLocalChecked
() ->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21708, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"keyed_load_result2\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
21709 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("y_from_obj")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21712, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"y_from_obj\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21710 ->Get(context.local(), v8_str("y_from_obj"))do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("y_from_obj")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21712, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"y_from_obj\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21711 .ToLocalChecked()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("y_from_obj")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21712, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"y_from_obj\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21712 ->IsUndefined())do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("y_from_obj")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21712, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"y_from_obj\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
21713 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("y_from_subobj")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21716, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"y_from_subobj\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21714 ->Get(context.local(), v8_str("y_from_subobj"))do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("y_from_subobj")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21716, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"y_from_subobj\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21715 .ToLocalChecked()do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("y_from_subobj")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21716, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"y_from_subobj\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
21716 ->IsUndefined())do { if ((__builtin_expect(!!(!(context->Global() ->Get
(context.local(), v8_str("y_from_subobj")) .ToLocalChecked() ->
IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21716, "Check failed: %s.", "context->Global() ->Get(context.local(), v8_str(\"y_from_subobj\")) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
21717}
21718
21719
21720THREADED_TEST(Regress142088)static void TestRegress142088(); RegisterThreadedTest register_Regress142088
(TestRegress142088, "Regress142088"); static void TestRegress142088
(); CcTest register_test_Regress142088(TestRegress142088, "../test/cctest/test-api.cc"
, "Regress142088", __null, true, true); static void TestRegress142088
()
{
21721 i::FLAG_allow_natives_syntax = true;
21722 LocalContext context;
21723 v8::Isolate* isolate = context->GetIsolate();
21724 v8::HandleScope scope(isolate);
21725 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
21726 templ->SetAccessor(v8_str("foo"),
21727 GetterWhichReturns42,
21728 SetterWhichSetsYOnThisTo23);
21729 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21732, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21730 ->Set(context.local(), v8_str("obj"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21732, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21731 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21732, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
21732 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("obj"), templ->NewInstance(context
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21732, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"obj\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
21733
21734 CompileRun("function load(x) { return x.foo; }"
21735 "var o = Object.create(obj);"
21736 "%OptimizeObjectForAddingMultipleProperties(obj, 1);"
21737 "load(o); load(o); load(o); load(o);");
21738}
21739
21740
21741THREADED_TEST(Regress137496)static void TestRegress137496(); RegisterThreadedTest register_Regress137496
(TestRegress137496, "Regress137496"); static void TestRegress137496
(); CcTest register_test_Regress137496(TestRegress137496, "../test/cctest/test-api.cc"
, "Regress137496", __null, true, true); static void TestRegress137496
()
{
21742 i::FLAG_expose_gc = true;
21743 LocalContext context;
21744 v8::HandleScope scope(context->GetIsolate());
21745
21746 // Compile a try-finally clause where the finally block causes a GC
21747 // while there still is a message pending for external reporting.
21748 TryCatch try_catch(context->GetIsolate());
21749 try_catch.SetVerbose(true);
21750 CompileRun("try { throw new Error(); } finally { gc(); }");
21751 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 21751, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
21752}
21753
21754
21755THREADED_TEST(Regress157124)static void TestRegress157124(); RegisterThreadedTest register_Regress157124
(TestRegress157124, "Regress157124"); static void TestRegress157124
(); CcTest register_test_Regress157124(TestRegress157124, "../test/cctest/test-api.cc"
, "Regress157124", __null, true, true); static void TestRegress157124
()
{
21756 LocalContext context;
21757 v8::Isolate* isolate = context->GetIsolate();
21758 v8::HandleScope scope(isolate);
21759 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
21760 Local<Object> obj = templ->NewInstance(context.local()).ToLocalChecked();
21761 obj->GetIdentityHash();
21762 obj->DeletePrivate(context.local(),
21763 v8::Private::ForApi(isolate, v8_str("Bug")))
21764 .FromJust();
21765}
21766
21767
21768THREADED_TEST(Regress2535)static void TestRegress2535(); RegisterThreadedTest register_Regress2535
(TestRegress2535, "Regress2535"); static void TestRegress2535
(); CcTest register_test_Regress2535(TestRegress2535, "../test/cctest/test-api.cc"
, "Regress2535", __null, true, true); static void TestRegress2535
()
{
21769 LocalContext context;
21770 v8::HandleScope scope(context->GetIsolate());
21771 Local<Value> set_value = CompileRun("new Set();");
21772 Local<Object> set_object(Local<Object>::Cast(set_value));
21773 CHECK_EQ(0, set_object->InternalFieldCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (set_object
->InternalFieldCount()), "0" " " "==" " " "set_object->InternalFieldCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21773, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21774 Local<Value> map_value = CompileRun("new Map();");
21775 Local<Object> map_object(Local<Object>::Cast(map_value));
21776 CHECK_EQ(0, map_object->InternalFieldCount())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (map_object
->InternalFieldCount()), "0" " " "==" " " "map_object->InternalFieldCount()"
)) { V8_Fatal("../test/cctest/test-api.cc", 21776, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21777}
21778
21779
21780THREADED_TEST(Regress2746)static void TestRegress2746(); RegisterThreadedTest register_Regress2746
(TestRegress2746, "Regress2746"); static void TestRegress2746
(); CcTest register_test_Regress2746(TestRegress2746, "../test/cctest/test-api.cc"
, "Regress2746", __null, true, true); static void TestRegress2746
()
{
21781 LocalContext context;
21782 v8::Isolate* isolate = context->GetIsolate();
21783 v8::HandleScope scope(isolate);
21784 Local<Object> obj = Object::New(isolate);
21785 Local<v8::Private> key = v8::Private::New(isolate, v8_str("key"));
21786 CHECK(do { if ((__builtin_expect(!!(!(obj->SetPrivate(context.local
(), key, v8::Undefined(isolate)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21787, "Check failed: %s.", "obj->SetPrivate(context.local(), key, v8::Undefined(isolate)).FromJust()"
); } } while (0)
21787 obj->SetPrivate(context.local(), key, v8::Undefined(isolate)).FromJust())do { if ((__builtin_expect(!!(!(obj->SetPrivate(context.local
(), key, v8::Undefined(isolate)).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21787, "Check failed: %s.", "obj->SetPrivate(context.local(), key, v8::Undefined(isolate)).FromJust()"
); } } while (0)
;
21788 Local<Value> value = obj->GetPrivate(context.local(), key).ToLocalChecked();
21789 CHECK(!value.IsEmpty())do { if ((__builtin_expect(!!(!(!value.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21789, "Check failed: %s.", "!value.IsEmpty()"
); } } while (0)
;
21790 CHECK(value->IsUndefined())do { if ((__builtin_expect(!!(!(value->IsUndefined())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 21790, "Check failed: %s."
, "value->IsUndefined()"); } } while (0)
;
21791}
21792
21793
21794THREADED_TEST(Regress260106)static void TestRegress260106(); RegisterThreadedTest register_Regress260106
(TestRegress260106, "Regress260106"); static void TestRegress260106
(); CcTest register_test_Regress260106(TestRegress260106, "../test/cctest/test-api.cc"
, "Regress260106", __null, true, true); static void TestRegress260106
()
{
21795 LocalContext context;
21796 v8::Isolate* isolate = context->GetIsolate();
21797 v8::HandleScope scope(isolate);
21798 Local<FunctionTemplate> templ = FunctionTemplate::New(isolate,
21799 DummyCallHandler);
21800 CompileRun("for (var i = 0; i < 128; i++) Object.prototype[i] = 0;");
21801 Local<Function> function =
21802 templ->GetFunction(context.local()).ToLocalChecked();
21803 CHECK(!function.IsEmpty())do { if ((__builtin_expect(!!(!(!function.IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 21803, "Check failed: %s."
, "!function.IsEmpty()"); } } while (0)
;
21804 CHECK(function->IsFunction())do { if ((__builtin_expect(!!(!(function->IsFunction())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 21804, "Check failed: %s."
, "function->IsFunction()"); } } while (0)
;
21805}
21806
21807
21808THREADED_TEST(JSONParseObject)static void TestJSONParseObject(); RegisterThreadedTest register_JSONParseObject
(TestJSONParseObject, "JSONParseObject"); static void TestJSONParseObject
(); CcTest register_test_JSONParseObject(TestJSONParseObject,
"../test/cctest/test-api.cc", "JSONParseObject", __null, true
, true); static void TestJSONParseObject()
{
21809 LocalContext context;
21810 HandleScope scope(context->GetIsolate());
21811 Local<Value> obj =
21812 v8::JSON::Parse(context->GetIsolate(), v8_str("{\"x\":42}"))
21813 .ToLocalChecked();
21814 Local<Object> global = context->Global();
21815 global->Set(context.local(), v8_str("obj"), obj).FromJust();
21816 ExpectString("JSON.stringify(obj)", "{\"x\":42}");
21817}
21818
21819
21820THREADED_TEST(JSONParseNumber)static void TestJSONParseNumber(); RegisterThreadedTest register_JSONParseNumber
(TestJSONParseNumber, "JSONParseNumber"); static void TestJSONParseNumber
(); CcTest register_test_JSONParseNumber(TestJSONParseNumber,
"../test/cctest/test-api.cc", "JSONParseNumber", __null, true
, true); static void TestJSONParseNumber()
{
21821 LocalContext context;
21822 HandleScope scope(context->GetIsolate());
21823 Local<Value> obj =
21824 v8::JSON::Parse(context->GetIsolate(), v8_str("42")).ToLocalChecked();
21825 Local<Object> global = context->Global();
21826 global->Set(context.local(), v8_str("obj"), obj).FromJust();
21827 ExpectString("JSON.stringify(obj)", "42");
21828}
21829
21830
21831#if V8_OS_POSIX1 && !V8_OS_NACL
21832class ThreadInterruptTest {
21833 public:
21834 ThreadInterruptTest() : sem_(0), sem_value_(0) { }
21835 ~ThreadInterruptTest() {}
21836
21837 void RunTest() {
21838 InterruptThread i_thread(this);
21839 i_thread.Start();
21840
21841 sem_.Wait();
21842 CHECK_EQ(kExpectedValue, sem_value_)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (kExpectedValue
), (sem_value_), "kExpectedValue" " " "==" " " "sem_value_"))
{ V8_Fatal("../test/cctest/test-api.cc", 21842, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
21843 }
21844
21845 private:
21846 static const int kExpectedValue = 1;
21847
21848 class InterruptThread : public v8::base::Thread {
21849 public:
21850 explicit InterruptThread(ThreadInterruptTest* test)
21851 : Thread(Options("InterruptThread")), test_(test) {}
21852
21853 virtual void Run() {
21854 struct sigaction action;
21855
21856 // Ensure that we'll enter waiting condition
21857 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100));
21858
21859 // Setup signal handler
21860 memset(&action, 0, sizeof(action));
21861 action.sa_handler__sigaction_handler.sa_handler = SignalHandler;
21862 sigaction(SIGCHLD17, &action, NULL__null);
21863
21864 // Send signal
21865 kill(getpid(), SIGCHLD17);
21866
21867 // Ensure that if wait has returned because of error
21868 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100));
21869
21870 // Set value and signal semaphore
21871 test_->sem_value_ = 1;
21872 test_->sem_.Signal();
21873 }
21874
21875 static void SignalHandler(int signal) {
21876 }
21877
21878 private:
21879 ThreadInterruptTest* test_;
21880 };
21881
21882 v8::base::Semaphore sem_;
21883 volatile int sem_value_;
21884};
21885
21886
21887THREADED_TEST(SemaphoreInterruption)static void TestSemaphoreInterruption(); RegisterThreadedTest
register_SemaphoreInterruption(TestSemaphoreInterruption, "SemaphoreInterruption"
); static void TestSemaphoreInterruption(); CcTest register_test_SemaphoreInterruption
(TestSemaphoreInterruption, "../test/cctest/test-api.cc", "SemaphoreInterruption"
, __null, true, true); static void TestSemaphoreInterruption(
)
{
21888 ThreadInterruptTest().RunTest();
21889}
21890
21891
21892#endif // V8_OS_POSIX
21893
21894
21895void UnreachableCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
21896 CHECK(false)do { if ((__builtin_expect(!!(!(false)), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 21896, "Check failed: %s.", "false"); } } while (0)
;
21897}
21898
21899
21900TEST(JSONStringifyAccessCheck)static void TestJSONStringifyAccessCheck(); CcTest register_test_JSONStringifyAccessCheck
(TestJSONStringifyAccessCheck, "../test/cctest/test-api.cc", "JSONStringifyAccessCheck"
, __null, true, true); static void TestJSONStringifyAccessCheck
()
{
21901 v8::V8::Initialize();
21902 v8::Isolate* isolate = CcTest::isolate();
21903 v8::HandleScope scope(isolate);
21904
21905 // Create an ObjectTemplate for global objects and install access
21906 // check callbacks that will block access.
21907 v8::Local<v8::ObjectTemplate> global_template =
21908 v8::ObjectTemplate::New(isolate);
21909 global_template->SetAccessCheckCallback(AccessAlwaysBlocked);
21910
21911 // Create a context and set an x property on it's global object.
21912 LocalContext context0(NULL__null, global_template);
21913 v8::Local<v8::Object> global0 = context0->Global();
21914 global0->Set(context0.local(), v8_str("x"), v8_num(42)).FromJust();
21915 ExpectString("JSON.stringify(this)", "{\"x\":42}");
21916
21917 for (int i = 0; i < 2; i++) {
21918 if (i == 1) {
21919 // Install a toJSON function on the second run.
21920 v8::Local<v8::FunctionTemplate> toJSON =
21921 v8::FunctionTemplate::New(isolate, UnreachableCallback);
21922
21923 global0->Set(context0.local(), v8_str("toJSON"),
21924 toJSON->GetFunction(context0.local()).ToLocalChecked())
21925 .FromJust();
21926 }
21927 // Create a context with a different security token so that the
21928 // failed access check callback will be called on each access.
21929 LocalContext context1(NULL__null, global_template);
21930 CHECK(context1->Global()do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 21932, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
21931 ->Set(context1.local(), v8_str("other"), global0)do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 21932, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
21932 .FromJust())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 21932, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
;
21933
21934 CHECK(CompileRun("JSON.stringify(other)").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("JSON.stringify(other)"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21934
, "Check failed: %s.", "CompileRun(\"JSON.stringify(other)\").IsEmpty()"
); } } while (0)
;
21935 CHECK(CompileRun("JSON.stringify({ 'a' : other, 'b' : ['c'] })").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("JSON.stringify({ 'a' : other, 'b' : ['c'] })"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21935
, "Check failed: %s.", "CompileRun(\"JSON.stringify({ 'a' : other, 'b' : ['c'] })\").IsEmpty()"
); } } while (0)
;
21936 CHECK(CompileRun("JSON.stringify([other, 'b', 'c'])").IsEmpty())do { if ((__builtin_expect(!!(!(CompileRun("JSON.stringify([other, 'b', 'c'])"
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 21936
, "Check failed: %s.", "CompileRun(\"JSON.stringify([other, 'b', 'c'])\").IsEmpty()"
); } } while (0)
;
21937 }
21938}
21939
21940
21941bool access_check_fail_thrown = false;
21942bool catch_callback_called = false;
21943
21944
21945// Failed access check callback that performs a GC on each invocation.
21946void FailedAccessCheckThrows(Local<v8::Object> target,
21947 v8::AccessType type,
21948 Local<v8::Value> data) {
21949 access_check_fail_thrown = true;
21950 i::PrintF("Access check failed. Error thrown.\n");
21951 CcTest::isolate()->ThrowException(
21952 v8::Exception::Error(v8_str("cross context")));
21953}
21954
21955
21956void CatcherCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
21957 for (int i = 0; i < args.Length(); i++) {
21958 i::PrintF("%s\n", *String::Utf8Value(args[i]));
21959 }
21960 catch_callback_called = true;
21961}
21962
21963
21964void HasOwnPropertyCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
21965 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
21966 CHECK(do { if ((__builtin_expect(!!(!(args[0] ->ToObject(context
) .ToLocalChecked() ->HasOwnProperty(context, args[1]->
ToString(context).ToLocalChecked()) .IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21971, "Check failed: %s.", "args[0] ->ToObject(context) .ToLocalChecked() ->HasOwnProperty(context, args[1]->ToString(context).ToLocalChecked()) .IsNothing()"
); } } while (0)
21967 args[0]do { if ((__builtin_expect(!!(!(args[0] ->ToObject(context
) .ToLocalChecked() ->HasOwnProperty(context, args[1]->
ToString(context).ToLocalChecked()) .IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21971, "Check failed: %s.", "args[0] ->ToObject(context) .ToLocalChecked() ->HasOwnProperty(context, args[1]->ToString(context).ToLocalChecked()) .IsNothing()"
); } } while (0)
21968 ->ToObject(context)do { if ((__builtin_expect(!!(!(args[0] ->ToObject(context
) .ToLocalChecked() ->HasOwnProperty(context, args[1]->
ToString(context).ToLocalChecked()) .IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21971, "Check failed: %s.", "args[0] ->ToObject(context) .ToLocalChecked() ->HasOwnProperty(context, args[1]->ToString(context).ToLocalChecked()) .IsNothing()"
); } } while (0)
21969 .ToLocalChecked()do { if ((__builtin_expect(!!(!(args[0] ->ToObject(context
) .ToLocalChecked() ->HasOwnProperty(context, args[1]->
ToString(context).ToLocalChecked()) .IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21971, "Check failed: %s.", "args[0] ->ToObject(context) .ToLocalChecked() ->HasOwnProperty(context, args[1]->ToString(context).ToLocalChecked()) .IsNothing()"
); } } while (0)
21970 ->HasOwnProperty(context, args[1]->ToString(context).ToLocalChecked())do { if ((__builtin_expect(!!(!(args[0] ->ToObject(context
) .ToLocalChecked() ->HasOwnProperty(context, args[1]->
ToString(context).ToLocalChecked()) .IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21971, "Check failed: %s.", "args[0] ->ToObject(context) .ToLocalChecked() ->HasOwnProperty(context, args[1]->ToString(context).ToLocalChecked()) .IsNothing()"
); } } while (0)
21971 .IsNothing())do { if ((__builtin_expect(!!(!(args[0] ->ToObject(context
) .ToLocalChecked() ->HasOwnProperty(context, args[1]->
ToString(context).ToLocalChecked()) .IsNothing())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 21971, "Check failed: %s.", "args[0] ->ToObject(context) .ToLocalChecked() ->HasOwnProperty(context, args[1]->ToString(context).ToLocalChecked()) .IsNothing()"
); } } while (0)
;
21972}
21973
21974
21975void CheckCorrectThrow(const char* script) {
21976 // Test that the script, when wrapped into a try-catch, triggers the catch
21977 // clause due to failed access check throwing an exception.
21978 // The subsequent try-catch should run without any exception.
21979 access_check_fail_thrown = false;
21980 catch_callback_called = false;
21981 i::ScopedVector<char> source(1024);
21982 i::SNPrintF(source, "try { %s; } catch (e) { catcher(e); }", script);
21983 CompileRun(source.start());
21984 CHECK(access_check_fail_thrown)do { if ((__builtin_expect(!!(!(access_check_fail_thrown)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 21984, "Check failed: %s."
, "access_check_fail_thrown"); } } while (0)
;
21985 CHECK(catch_callback_called)do { if ((__builtin_expect(!!(!(catch_callback_called)), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 21985, "Check failed: %s."
, "catch_callback_called"); } } while (0)
;
21986
21987 access_check_fail_thrown = false;
21988 catch_callback_called = false;
21989 CompileRun("try { [1, 2, 3].sort(); } catch (e) { catcher(e) };");
21990 CHECK(!access_check_fail_thrown)do { if ((__builtin_expect(!!(!(!access_check_fail_thrown)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 21990, "Check failed: %s."
, "!access_check_fail_thrown"); } } while (0)
;
21991 CHECK(!catch_callback_called)do { if ((__builtin_expect(!!(!(!catch_callback_called)), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 21991, "Check failed: %s."
, "!catch_callback_called"); } } while (0)
;
21992}
21993
21994
21995TEST(AccessCheckThrows)static void TestAccessCheckThrows(); CcTest register_test_AccessCheckThrows
(TestAccessCheckThrows, "../test/cctest/test-api.cc", "AccessCheckThrows"
, __null, true, true); static void TestAccessCheckThrows()
{
21996 i::FLAG_allow_natives_syntax = true;
21997 v8::V8::Initialize();
21998 v8::Isolate* isolate = CcTest::isolate();
21999 isolate->SetFailedAccessCheckCallbackFunction(&FailedAccessCheckThrows);
22000 v8::HandleScope scope(isolate);
22001
22002 // Create an ObjectTemplate for global objects and install access
22003 // check callbacks that will block access.
22004 v8::Local<v8::ObjectTemplate> global_template =
22005 v8::ObjectTemplate::New(isolate);
22006 global_template->SetAccessCheckCallback(AccessAlwaysBlocked);
22007
22008 // Create a context and set an x property on it's global object.
22009 LocalContext context0(NULL__null, global_template);
22010 v8::Local<v8::Object> global0 = context0->Global();
22011
22012 // Create a context with a different security token so that the
22013 // failed access check callback will be called on each access.
22014 LocalContext context1(NULL__null, global_template);
22015 CHECK(context1->Global()do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 22017, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
22016 ->Set(context1.local(), v8_str("other"), global0)do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 22017, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
22017 .FromJust())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("other"), global0) .FromJust())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 22017, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"other\"), global0) .FromJust()"
); } } while (0)
;
22018
22019 v8::Local<v8::FunctionTemplate> catcher_fun =
22020 v8::FunctionTemplate::New(isolate, CatcherCallback);
22021 CHECK(context1->Global()do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("catcher"), catcher_fun->GetFunction
(context1.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22024, "Check failed: %s.", "context1->Global() ->Set(context1.local(), v8_str(\"catcher\"), catcher_fun->GetFunction(context1.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22022 ->Set(context1.local(), v8_str("catcher"),do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("catcher"), catcher_fun->GetFunction
(context1.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22024, "Check failed: %s.", "context1->Global() ->Set(context1.local(), v8_str(\"catcher\"), catcher_fun->GetFunction(context1.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22023 catcher_fun->GetFunction(context1.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("catcher"), catcher_fun->GetFunction
(context1.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22024, "Check failed: %s.", "context1->Global() ->Set(context1.local(), v8_str(\"catcher\"), catcher_fun->GetFunction(context1.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22024 .FromJust())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("catcher"), catcher_fun->GetFunction
(context1.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22024, "Check failed: %s.", "context1->Global() ->Set(context1.local(), v8_str(\"catcher\"), catcher_fun->GetFunction(context1.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
22025
22026 v8::Local<v8::FunctionTemplate> has_own_property_fun =
22027 v8::FunctionTemplate::New(isolate, HasOwnPropertyCallback);
22028 CHECK(context1->Global()do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("has_own_property"), has_own_property_fun
->GetFunction(context1.local()) .ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22032, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"has_own_property\"), has_own_property_fun->GetFunction(context1.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
22029 ->Set(context1.local(), v8_str("has_own_property"),do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("has_own_property"), has_own_property_fun
->GetFunction(context1.local()) .ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22032, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"has_own_property\"), has_own_property_fun->GetFunction(context1.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
22030 has_own_property_fun->GetFunction(context1.local())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("has_own_property"), has_own_property_fun
->GetFunction(context1.local()) .ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22032, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"has_own_property\"), has_own_property_fun->GetFunction(context1.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
22031 .ToLocalChecked())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("has_own_property"), has_own_property_fun
->GetFunction(context1.local()) .ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22032, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"has_own_property\"), has_own_property_fun->GetFunction(context1.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
22032 .FromJust())do { if ((__builtin_expect(!!(!(context1->Global() ->Set
(context1.local(), v8_str("has_own_property"), has_own_property_fun
->GetFunction(context1.local()) .ToLocalChecked()) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22032, "Check failed: %s."
, "context1->Global() ->Set(context1.local(), v8_str(\"has_own_property\"), has_own_property_fun->GetFunction(context1.local()) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
22033
22034 {
22035 v8::TryCatch try_catch(isolate);
22036 access_check_fail_thrown = false;
22037 CompileRun("other.x;");
22038 CHECK(access_check_fail_thrown)do { if ((__builtin_expect(!!(!(access_check_fail_thrown)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 22038, "Check failed: %s."
, "access_check_fail_thrown"); } } while (0)
;
22039 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22039, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
22040 }
22041
22042 CheckCorrectThrow("other.x");
22043 CheckCorrectThrow("other[1]");
22044 CheckCorrectThrow("JSON.stringify(other)");
22045 CheckCorrectThrow("has_own_property(other, 'x')");
22046 CheckCorrectThrow("%GetProperty(other, 'x')");
22047 CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 0)");
22048 CheckCorrectThrow("%AddNamedProperty(other, 'x', 'foo', 1)");
22049 CheckCorrectThrow("%DeleteProperty_Sloppy(other, 'x')");
22050 CheckCorrectThrow("%DeleteProperty_Strict(other, 'x')");
22051 CheckCorrectThrow("%DeleteProperty_Sloppy(other, '1')");
22052 CheckCorrectThrow("%DeleteProperty_Strict(other, '1')");
22053 CheckCorrectThrow("%HasOwnProperty(other, 'x')");
22054 CheckCorrectThrow("%HasProperty('x', other)");
22055 CheckCorrectThrow("%PropertyIsEnumerable(other, 'x')");
22056 // PROPERTY_ATTRIBUTES_NONE = 0
22057 CheckCorrectThrow("%DefineAccessorPropertyUnchecked("
22058 "other, 'x', null, null, 1)");
22059
22060 // Reset the failed access check callback so it does not influence
22061 // the other tests.
22062 isolate->SetFailedAccessCheckCallbackFunction(NULL__null);
22063}
22064
22065
22066class RequestInterruptTestBase {
22067 public:
22068 RequestInterruptTestBase()
22069 : env_(),
22070 isolate_(env_->GetIsolate()),
22071 sem_(0),
22072 warmup_(20000),
22073 should_continue_(true) {
22074 }
22075
22076 virtual ~RequestInterruptTestBase() { }
22077
22078 virtual void StartInterruptThread() = 0;
22079
22080 virtual void TestBody() = 0;
22081
22082 void RunTest() {
22083 StartInterruptThread();
22084
22085 v8::HandleScope handle_scope(isolate_);
22086
22087 TestBody();
22088
22089 // Verify we arrived here because interruptor was called
22090 // not due to a bug causing us to exit the loop too early.
22091 CHECK(!should_continue())do { if ((__builtin_expect(!!(!(!should_continue())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22091, "Check failed: %s.", "!should_continue()"
); } } while (0)
;
22092 }
22093
22094 void WakeUpInterruptor() {
22095 sem_.Signal();
22096 }
22097
22098 bool should_continue() const { return should_continue_; }
22099
22100 bool ShouldContinue() {
22101 if (warmup_ > 0) {
22102 if (--warmup_ == 0) {
22103 WakeUpInterruptor();
22104 }
22105 }
22106
22107 return should_continue_;
22108 }
22109
22110 static void ShouldContinueCallback(
22111 const v8::FunctionCallbackInfo<Value>& info) {
22112 RequestInterruptTestBase* test =
22113 reinterpret_cast<RequestInterruptTestBase*>(
22114 info.Data().As<v8::External>()->Value());
22115 info.GetReturnValue().Set(test->ShouldContinue());
22116 }
22117
22118 LocalContext env_;
22119 v8::Isolate* isolate_;
22120 v8::base::Semaphore sem_;
22121 int warmup_;
22122 bool should_continue_;
22123};
22124
22125
22126class RequestInterruptTestBaseWithSimpleInterrupt
22127 : public RequestInterruptTestBase {
22128 public:
22129 RequestInterruptTestBaseWithSimpleInterrupt() : i_thread(this) { }
22130
22131 virtual void StartInterruptThread() {
22132 i_thread.Start();
22133 }
22134
22135 private:
22136 class InterruptThread : public v8::base::Thread {
22137 public:
22138 explicit InterruptThread(RequestInterruptTestBase* test)
22139 : Thread(Options("RequestInterruptTest")), test_(test) {}
22140
22141 virtual void Run() {
22142 test_->sem_.Wait();
22143 test_->isolate_->RequestInterrupt(&OnInterrupt, test_);
22144 }
22145
22146 static void OnInterrupt(v8::Isolate* isolate, void* data) {
22147 reinterpret_cast<RequestInterruptTestBase*>(data)->
22148 should_continue_ = false;
22149 }
22150
22151 private:
22152 RequestInterruptTestBase* test_;
22153 };
22154
22155 InterruptThread i_thread;
22156};
22157
22158
22159class RequestInterruptTestWithFunctionCall
22160 : public RequestInterruptTestBaseWithSimpleInterrupt {
22161 public:
22162 virtual void TestBody() {
22163 Local<Function> func = Function::New(env_.local(), ShouldContinueCallback,
22164 v8::External::New(isolate_, this))
22165 .ToLocalChecked();
22166 CHECK(env_->Global()do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("ShouldContinue"), func) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22168, "Check failed: %s."
, "env_->Global() ->Set(env_.local(), v8_str(\"ShouldContinue\"), func) .FromJust()"
); } } while (0)
22167 ->Set(env_.local(), v8_str("ShouldContinue"), func)do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("ShouldContinue"), func) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22168, "Check failed: %s."
, "env_->Global() ->Set(env_.local(), v8_str(\"ShouldContinue\"), func) .FromJust()"
); } } while (0)
22168 .FromJust())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("ShouldContinue"), func) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22168, "Check failed: %s."
, "env_->Global() ->Set(env_.local(), v8_str(\"ShouldContinue\"), func) .FromJust()"
); } } while (0)
;
22169
22170 CompileRun("while (ShouldContinue()) { }");
22171 }
22172};
22173
22174
22175class RequestInterruptTestWithMethodCall
22176 : public RequestInterruptTestBaseWithSimpleInterrupt {
22177 public:
22178 virtual void TestBody() {
22179 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_);
22180 v8::Local<v8::Template> proto = t->PrototypeTemplate();
22181 proto->Set(v8_str("shouldContinue"),
22182 FunctionTemplate::New(isolate_, ShouldContinueCallback,
22183 v8::External::New(isolate_, this)));
22184 CHECK(env_->Global()do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22187, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22185 ->Set(env_.local(), v8_str("Klass"),do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22187, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22186 t->GetFunction(env_.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22187, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22187 .FromJust())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22187, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
22188
22189 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }");
22190 }
22191};
22192
22193
22194class RequestInterruptTestWithAccessor
22195 : public RequestInterruptTestBaseWithSimpleInterrupt {
22196 public:
22197 virtual void TestBody() {
22198 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_);
22199 v8::Local<v8::Template> proto = t->PrototypeTemplate();
22200 proto->SetAccessorProperty(v8_str("shouldContinue"), FunctionTemplate::New(
22201 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this)));
22202 CHECK(env_->Global()do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22205, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22203 ->Set(env_.local(), v8_str("Klass"),do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22205, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22204 t->GetFunction(env_.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22205, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22205 .FromJust())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22205, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
22206
22207 CompileRun("var obj = new Klass; while (obj.shouldContinue) { }");
22208 }
22209};
22210
22211
22212class RequestInterruptTestWithNativeAccessor
22213 : public RequestInterruptTestBaseWithSimpleInterrupt {
22214 public:
22215 virtual void TestBody() {
22216 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_);
22217 t->InstanceTemplate()->SetNativeDataProperty(
22218 v8_str("shouldContinue"),
22219 &ShouldContinueNativeGetter,
22220 NULL__null,
22221 v8::External::New(isolate_, this));
22222 CHECK(env_->Global()do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22225, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22223 ->Set(env_.local(), v8_str("Klass"),do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22225, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22224 t->GetFunction(env_.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22225, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22225 .FromJust())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22225, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
22226
22227 CompileRun("var obj = new Klass; while (obj.shouldContinue) { }");
22228 }
22229
22230 private:
22231 static void ShouldContinueNativeGetter(
22232 Local<String> property,
22233 const v8::PropertyCallbackInfo<v8::Value>& info) {
22234 RequestInterruptTestBase* test =
22235 reinterpret_cast<RequestInterruptTestBase*>(
22236 info.Data().As<v8::External>()->Value());
22237 info.GetReturnValue().Set(test->ShouldContinue());
22238 }
22239};
22240
22241
22242class RequestInterruptTestWithMethodCallAndInterceptor
22243 : public RequestInterruptTestBaseWithSimpleInterrupt {
22244 public:
22245 virtual void TestBody() {
22246 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_);
22247 v8::Local<v8::Template> proto = t->PrototypeTemplate();
22248 proto->Set(v8_str("shouldContinue"),
22249 FunctionTemplate::New(isolate_, ShouldContinueCallback,
22250 v8::External::New(isolate_, this)));
22251 v8::Local<v8::ObjectTemplate> instance_template = t->InstanceTemplate();
22252 instance_template->SetHandler(
22253 v8::NamedPropertyHandlerConfiguration(EmptyInterceptor));
22254
22255 CHECK(env_->Global()do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22258, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22256 ->Set(env_.local(), v8_str("Klass"),do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22258, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22257 t->GetFunction(env_.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22258, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22258 .FromJust())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("Klass"), t->GetFunction(env_.local()).ToLocalChecked
()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22258, "Check failed: %s.", "env_->Global() ->Set(env_.local(), v8_str(\"Klass\"), t->GetFunction(env_.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
22259
22260 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }");
22261 }
22262
22263 private:
22264 static void EmptyInterceptor(
22265 Local<Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) {}
22266};
22267
22268
22269class RequestInterruptTestWithMathAbs
22270 : public RequestInterruptTestBaseWithSimpleInterrupt {
22271 public:
22272 virtual void TestBody() {
22273 env_->Global()
22274 ->Set(env_.local(), v8_str("WakeUpInterruptor"),
22275 Function::New(env_.local(), WakeUpInterruptorCallback,
22276 v8::External::New(isolate_, this))
22277 .ToLocalChecked())
22278 .FromJust();
22279
22280 env_->Global()
22281 ->Set(env_.local(), v8_str("ShouldContinue"),
22282 Function::New(env_.local(), ShouldContinueCallback,
22283 v8::External::New(isolate_, this))
22284 .ToLocalChecked())
22285 .FromJust();
22286
22287 i::FLAG_allow_natives_syntax = true;
22288 CompileRun("function loopish(o) {"
22289 " var pre = 10;"
22290 " while (o.abs(1) > 0) {"
22291 " if (o.abs(1) >= 0 && !ShouldContinue()) break;"
22292 " if (pre > 0) {"
22293 " if (--pre === 0) WakeUpInterruptor(o === Math);"
22294 " }"
22295 " }"
22296 "}"
22297 "var i = 50;"
22298 "var obj = {abs: function () { return i-- }, x: null};"
22299 "delete obj.x;"
22300 "loopish(obj);"
22301 "%OptimizeFunctionOnNextCall(loopish);"
22302 "loopish(Math);");
22303
22304 i::FLAG_allow_natives_syntax = false;
22305 }
22306
22307 private:
22308 static void WakeUpInterruptorCallback(
22309 const v8::FunctionCallbackInfo<Value>& info) {
22310 if (!info[0]
22311 ->BooleanValue(info.GetIsolate()->GetCurrentContext())
22312 .FromJust()) {
22313 return;
22314 }
22315
22316 RequestInterruptTestBase* test =
22317 reinterpret_cast<RequestInterruptTestBase*>(
22318 info.Data().As<v8::External>()->Value());
22319 test->WakeUpInterruptor();
22320 }
22321
22322 static void ShouldContinueCallback(
22323 const v8::FunctionCallbackInfo<Value>& info) {
22324 RequestInterruptTestBase* test =
22325 reinterpret_cast<RequestInterruptTestBase*>(
22326 info.Data().As<v8::External>()->Value());
22327 info.GetReturnValue().Set(test->should_continue());
22328 }
22329};
22330
22331
22332TEST(RequestInterruptTestWithFunctionCall)static void TestRequestInterruptTestWithFunctionCall(); CcTest
register_test_RequestInterruptTestWithFunctionCall(TestRequestInterruptTestWithFunctionCall
, "../test/cctest/test-api.cc", "RequestInterruptTestWithFunctionCall"
, __null, true, true); static void TestRequestInterruptTestWithFunctionCall
()
{
22333 RequestInterruptTestWithFunctionCall().RunTest();
22334}
22335
22336
22337TEST(RequestInterruptTestWithMethodCall)static void TestRequestInterruptTestWithMethodCall(); CcTest register_test_RequestInterruptTestWithMethodCall
(TestRequestInterruptTestWithMethodCall, "../test/cctest/test-api.cc"
, "RequestInterruptTestWithMethodCall", __null, true, true); static
void TestRequestInterruptTestWithMethodCall()
{
22338 RequestInterruptTestWithMethodCall().RunTest();
22339}
22340
22341
22342TEST(RequestInterruptTestWithAccessor)static void TestRequestInterruptTestWithAccessor(); CcTest register_test_RequestInterruptTestWithAccessor
(TestRequestInterruptTestWithAccessor, "../test/cctest/test-api.cc"
, "RequestInterruptTestWithAccessor", __null, true, true); static
void TestRequestInterruptTestWithAccessor()
{
22343 RequestInterruptTestWithAccessor().RunTest();
22344}
22345
22346
22347TEST(RequestInterruptTestWithNativeAccessor)static void TestRequestInterruptTestWithNativeAccessor(); CcTest
register_test_RequestInterruptTestWithNativeAccessor(TestRequestInterruptTestWithNativeAccessor
, "../test/cctest/test-api.cc", "RequestInterruptTestWithNativeAccessor"
, __null, true, true); static void TestRequestInterruptTestWithNativeAccessor
()
{
22348 RequestInterruptTestWithNativeAccessor().RunTest();
22349}
22350
22351
22352TEST(RequestInterruptTestWithMethodCallAndInterceptor)static void TestRequestInterruptTestWithMethodCallAndInterceptor
(); CcTest register_test_RequestInterruptTestWithMethodCallAndInterceptor
(TestRequestInterruptTestWithMethodCallAndInterceptor, "../test/cctest/test-api.cc"
, "RequestInterruptTestWithMethodCallAndInterceptor", __null,
true, true); static void TestRequestInterruptTestWithMethodCallAndInterceptor
()
{
22353 RequestInterruptTestWithMethodCallAndInterceptor().RunTest();
22354}
22355
22356
22357TEST(RequestInterruptTestWithMathAbs)static void TestRequestInterruptTestWithMathAbs(); CcTest register_test_RequestInterruptTestWithMathAbs
(TestRequestInterruptTestWithMathAbs, "../test/cctest/test-api.cc"
, "RequestInterruptTestWithMathAbs", __null, true, true); static
void TestRequestInterruptTestWithMathAbs()
{
22358 RequestInterruptTestWithMathAbs().RunTest();
22359}
22360
22361
22362class RequestMultipleInterrupts : public RequestInterruptTestBase {
22363 public:
22364 RequestMultipleInterrupts() : i_thread(this), counter_(0) {}
22365
22366 virtual void StartInterruptThread() {
22367 i_thread.Start();
22368 }
22369
22370 virtual void TestBody() {
22371 Local<Function> func = Function::New(env_.local(), ShouldContinueCallback,
22372 v8::External::New(isolate_, this))
22373 .ToLocalChecked();
22374 CHECK(env_->Global()do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("ShouldContinue"), func) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22376, "Check failed: %s."
, "env_->Global() ->Set(env_.local(), v8_str(\"ShouldContinue\"), func) .FromJust()"
); } } while (0)
22375 ->Set(env_.local(), v8_str("ShouldContinue"), func)do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("ShouldContinue"), func) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22376, "Check failed: %s."
, "env_->Global() ->Set(env_.local(), v8_str(\"ShouldContinue\"), func) .FromJust()"
); } } while (0)
22376 .FromJust())do { if ((__builtin_expect(!!(!(env_->Global() ->Set(env_
.local(), v8_str("ShouldContinue"), func) .FromJust())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22376, "Check failed: %s."
, "env_->Global() ->Set(env_.local(), v8_str(\"ShouldContinue\"), func) .FromJust()"
); } } while (0)
;
22377
22378 CompileRun("while (ShouldContinue()) { }");
22379 }
22380
22381 private:
22382 class InterruptThread : public v8::base::Thread {
22383 public:
22384 enum { NUM_INTERRUPTS = 10 };
22385 explicit InterruptThread(RequestMultipleInterrupts* test)
22386 : Thread(Options("RequestInterruptTest")), test_(test) {}
22387
22388 virtual void Run() {
22389 test_->sem_.Wait();
22390 for (int i = 0; i < NUM_INTERRUPTS; i++) {
22391 test_->isolate_->RequestInterrupt(&OnInterrupt, test_);
22392 }
22393 }
22394
22395 static void OnInterrupt(v8::Isolate* isolate, void* data) {
22396 RequestMultipleInterrupts* test =
22397 reinterpret_cast<RequestMultipleInterrupts*>(data);
22398 test->should_continue_ = ++test->counter_ < NUM_INTERRUPTS;
22399 }
22400
22401 private:
22402 RequestMultipleInterrupts* test_;
22403 };
22404
22405 InterruptThread i_thread;
22406 int counter_;
22407};
22408
22409
22410TEST(RequestMultipleInterrupts)static void TestRequestMultipleInterrupts(); CcTest register_test_RequestMultipleInterrupts
(TestRequestMultipleInterrupts, "../test/cctest/test-api.cc",
"RequestMultipleInterrupts", __null, true, true); static void
TestRequestMultipleInterrupts()
{ RequestMultipleInterrupts().RunTest(); }
22411
22412
22413static bool interrupt_was_called = false;
22414
22415
22416void SmallScriptsInterruptCallback(v8::Isolate* isolate, void* data) {
22417 interrupt_was_called = true;
22418}
22419
22420
22421TEST(RequestInterruptSmallScripts)static void TestRequestInterruptSmallScripts(); CcTest register_test_RequestInterruptSmallScripts
(TestRequestInterruptSmallScripts, "../test/cctest/test-api.cc"
, "RequestInterruptSmallScripts", __null, true, true); static
void TestRequestInterruptSmallScripts()
{
22422 LocalContext env;
22423 v8::Isolate* isolate = CcTest::isolate();
22424 v8::HandleScope scope(isolate);
22425
22426 interrupt_was_called = false;
22427 isolate->RequestInterrupt(&SmallScriptsInterruptCallback, NULL__null);
22428 CompileRun("(function(x){return x;})(1);");
22429 CHECK(interrupt_was_called)do { if ((__builtin_expect(!!(!(interrupt_was_called)), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 22429, "Check failed: %s."
, "interrupt_was_called"); } } while (0)
;
22430}
22431
22432
22433static Local<Value> function_new_expected_env;
22434static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) {
22435 CHECK(do { if ((__builtin_expect(!!(!(function_new_expected_env->
Equals(info.GetIsolate()->GetCurrentContext(), info.Data()
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22438, "Check failed: %s.", "function_new_expected_env->Equals(info.GetIsolate()->GetCurrentContext(), info.Data()) .FromJust()"
); } } while (0)
22436 function_new_expected_env->Equals(info.GetIsolate()->GetCurrentContext(),do { if ((__builtin_expect(!!(!(function_new_expected_env->
Equals(info.GetIsolate()->GetCurrentContext(), info.Data()
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22438, "Check failed: %s.", "function_new_expected_env->Equals(info.GetIsolate()->GetCurrentContext(), info.Data()) .FromJust()"
); } } while (0)
22437 info.Data())do { if ((__builtin_expect(!!(!(function_new_expected_env->
Equals(info.GetIsolate()->GetCurrentContext(), info.Data()
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22438, "Check failed: %s.", "function_new_expected_env->Equals(info.GetIsolate()->GetCurrentContext(), info.Data()) .FromJust()"
); } } while (0)
22438 .FromJust())do { if ((__builtin_expect(!!(!(function_new_expected_env->
Equals(info.GetIsolate()->GetCurrentContext(), info.Data()
) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22438, "Check failed: %s.", "function_new_expected_env->Equals(info.GetIsolate()->GetCurrentContext(), info.Data()) .FromJust()"
); } } while (0)
;
22439 info.GetReturnValue().Set(17);
22440}
22441
22442
22443THREADED_TEST(FunctionNew)static void TestFunctionNew(); RegisterThreadedTest register_FunctionNew
(TestFunctionNew, "FunctionNew"); static void TestFunctionNew
(); CcTest register_test_FunctionNew(TestFunctionNew, "../test/cctest/test-api.cc"
, "FunctionNew", __null, true, true); static void TestFunctionNew
()
{
22444 LocalContext env;
22445 v8::Isolate* isolate = env->GetIsolate();
22446 v8::HandleScope scope(isolate);
22447 Local<Object> data = v8::Object::New(isolate);
22448 function_new_expected_env = data;
22449 Local<Function> func =
22450 Function::New(env.local(), FunctionNewCallback, data).ToLocalChecked();
22451 CHECK(env->Global()->Set(env.local(), v8_str("func"), func).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("func"), func).FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 22451, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"func\"), func).FromJust()"
); } } while (0)
;
22452 Local<Value> result = CompileRun("func();");
22453 CHECK(v8::Integer::New(isolate, 17)->Equals(env.local(), result).FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 17)
->Equals(env.local(), result).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22453, "Check failed: %s.", "v8::Integer::New(isolate, 17)->Equals(env.local(), result).FromJust()"
); } } while (0)
;
22454 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
22455 // Verify function not cached
22456 auto serial_number = handle(
22457 i::Smi::cast(i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*func))
22458 ->shared()
22459 ->get_api_func_data()
22460 ->serial_number()),
22461 i_isolate);
22462 auto cache = i_isolate->template_instantiations_cache();
22463 CHECK(cache->Lookup(serial_number)->IsTheHole())do { if ((__builtin_expect(!!(!(cache->Lookup(serial_number
)->IsTheHole())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22463, "Check failed: %s.", "cache->Lookup(serial_number)->IsTheHole()"
); } } while (0)
;
22464 // Verify that each Function::New creates a new function instance
22465 Local<Object> data2 = v8::Object::New(isolate);
22466 function_new_expected_env = data2;
22467 Local<Function> func2 =
22468 Function::New(env.local(), FunctionNewCallback, data2).ToLocalChecked();
22469 CHECK(!func2->IsNull())do { if ((__builtin_expect(!!(!(!func2->IsNull())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 22469, "Check failed: %s."
, "!func2->IsNull()"); } } while (0)
;
22470 CHECK(!func->Equals(env.local(), func2).FromJust())do { if ((__builtin_expect(!!(!(!func->Equals(env.local(),
func2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22470, "Check failed: %s.", "!func->Equals(env.local(), func2).FromJust()"
); } } while (0)
;
22471 CHECK(env->Global()->Set(env.local(), v8_str("func2"), func2).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("func2"), func2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22471, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"func2\"), func2).FromJust()"
); } } while (0)
;
22472 Local<Value> result2 = CompileRun("func2();");
22473 CHECK(v8::Integer::New(isolate, 17)->Equals(env.local(), result2).FromJust())do { if ((__builtin_expect(!!(!(v8::Integer::New(isolate, 17)
->Equals(env.local(), result2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22473, "Check failed: %s.", "v8::Integer::New(isolate, 17)->Equals(env.local(), result2).FromJust()"
); } } while (0)
;
22474}
22475
22476
22477TEST(EscapeableHandleScope)static void TestEscapeableHandleScope(); CcTest register_test_EscapeableHandleScope
(TestEscapeableHandleScope, "../test/cctest/test-api.cc", "EscapeableHandleScope"
, __null, true, true); static void TestEscapeableHandleScope(
)
{
22478 HandleScope outer_scope(CcTest::isolate());
22479 LocalContext context;
22480 const int runs = 10;
22481 Local<String> values[runs];
22482 for (int i = 0; i < runs; i++) {
22483 v8::EscapableHandleScope inner_scope(CcTest::isolate());
22484 Local<String> value;
22485 if (i != 0) value = v8_str("escape value");
22486 values[i] = inner_scope.Escape(value);
22487 }
22488 for (int i = 0; i < runs; i++) {
22489 Local<String> expected;
22490 if (i != 0) {
22491 CHECK(v8_str("escape value")do { if ((__builtin_expect(!!(!(v8_str("escape value") ->Equals
(context.local(), values[i]) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22493, "Check failed: %s.", "v8_str(\"escape value\") ->Equals(context.local(), values[i]) .FromJust()"
); } } while (0)
22492 ->Equals(context.local(), values[i])do { if ((__builtin_expect(!!(!(v8_str("escape value") ->Equals
(context.local(), values[i]) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22493, "Check failed: %s.", "v8_str(\"escape value\") ->Equals(context.local(), values[i]) .FromJust()"
); } } while (0)
22493 .FromJust())do { if ((__builtin_expect(!!(!(v8_str("escape value") ->Equals
(context.local(), values[i]) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22493, "Check failed: %s.", "v8_str(\"escape value\") ->Equals(context.local(), values[i]) .FromJust()"
); } } while (0)
;
22494 } else {
22495 CHECK(values[i].IsEmpty())do { if ((__builtin_expect(!!(!(values[i].IsEmpty())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 22495, "Check failed: %s."
, "values[i].IsEmpty()"); } } while (0)
;
22496 }
22497 }
22498}
22499
22500
22501static void SetterWhichExpectsThisAndHolderToDiffer(
22502 Local<String>, Local<Value>, const v8::PropertyCallbackInfo<void>& info) {
22503 CHECK(info.Holder() != info.This())do { if ((__builtin_expect(!!(!(info.Holder() != info.This())
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22503, "Check failed: %s."
, "info.Holder() != info.This()"); } } while (0)
;
22504}
22505
22506
22507TEST(Regress239669)static void TestRegress239669(); CcTest register_test_Regress239669
(TestRegress239669, "../test/cctest/test-api.cc", "Regress239669"
, __null, true, true); static void TestRegress239669()
{
22508 LocalContext context;
22509 v8::Isolate* isolate = context->GetIsolate();
22510 v8::HandleScope scope(isolate);
22511 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
22512 templ->SetAccessor(v8_str("x"), 0, SetterWhichExpectsThisAndHolderToDiffer);
22513 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22516, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22514 ->Set(context.local(), v8_str("P"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22516, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22515 templ->NewInstance(context.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22516, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
22516 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context.local(), v8_str("P"), templ->NewInstance(context.
local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22516, "Check failed: %s.", "context->Global() ->Set(context.local(), v8_str(\"P\"), templ->NewInstance(context.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
22517 CompileRun(
22518 "function C1() {"
22519 " this.x = 23;"
22520 "};"
22521 "C1.prototype = P;"
22522 "for (var i = 0; i < 4; i++ ) {"
22523 " new C1();"
22524 "}");
22525}
22526
22527
22528class ApiCallOptimizationChecker {
22529 private:
22530 static Local<Object> data;
22531 static Local<Object> receiver;
22532 static Local<Object> holder;
22533 static Local<Object> callee;
22534 static int count;
22535
22536 static void OptimizationCallback(
22537 const v8::FunctionCallbackInfo<v8::Value>& info) {
22538 CHECK(data == info.Data())do { if ((__builtin_expect(!!(!(data == info.Data())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 22538, "Check failed: %s."
, "data == info.Data()"); } } while (0)
;
22539 CHECK(receiver == info.This())do { if ((__builtin_expect(!!(!(receiver == info.This())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 22539, "Check failed: %s."
, "receiver == info.This()"); } } while (0)
;
22540 if (info.Length() == 1) {
22541 CHECK(v8_num(1)do { if ((__builtin_expect(!!(!(v8_num(1) ->Equals(info.GetIsolate
()->GetCurrentContext(), info[0]) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22543, "Check failed: %s.", "v8_num(1) ->Equals(info.GetIsolate()->GetCurrentContext(), info[0]) .FromJust()"
); } } while (0)
22542 ->Equals(info.GetIsolate()->GetCurrentContext(), info[0])do { if ((__builtin_expect(!!(!(v8_num(1) ->Equals(info.GetIsolate
()->GetCurrentContext(), info[0]) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22543, "Check failed: %s.", "v8_num(1) ->Equals(info.GetIsolate()->GetCurrentContext(), info[0]) .FromJust()"
); } } while (0)
22543 .FromJust())do { if ((__builtin_expect(!!(!(v8_num(1) ->Equals(info.GetIsolate
()->GetCurrentContext(), info[0]) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22543, "Check failed: %s.", "v8_num(1) ->Equals(info.GetIsolate()->GetCurrentContext(), info[0]) .FromJust()"
); } } while (0)
;
22544 }
22545 CHECK(holder == info.Holder())do { if ((__builtin_expect(!!(!(holder == info.Holder())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 22545, "Check failed: %s."
, "holder == info.Holder()"); } } while (0)
;
22546 count++;
22547 info.GetReturnValue().Set(v8_str("returned"));
22548 }
22549
22550 public:
22551 enum SignatureType {
22552 kNoSignature,
22553 kSignatureOnReceiver,
22554 kSignatureOnPrototype
22555 };
22556
22557 void RunAll() {
22558 SignatureType signature_types[] =
22559 {kNoSignature, kSignatureOnReceiver, kSignatureOnPrototype};
22560 for (unsigned i = 0; i < arraysize(signature_types)(sizeof(ArraySizeHelper(signature_types))); i++) {
22561 SignatureType signature_type = signature_types[i];
22562 for (int j = 0; j < 2; j++) {
22563 bool global = j == 0;
22564 int key = signature_type +
22565 arraysize(signature_types)(sizeof(ArraySizeHelper(signature_types))) * (global ? 1 : 0);
22566 Run(signature_type, global, key);
22567 }
22568 }
22569 }
22570
22571 void Run(SignatureType signature_type, bool global, int key) {
22572 v8::Isolate* isolate = CcTest::isolate();
22573 v8::HandleScope scope(isolate);
22574 // Build a template for signature checks.
22575 Local<v8::ObjectTemplate> signature_template;
22576 Local<v8::Signature> signature;
22577 {
22578 Local<v8::FunctionTemplate> parent_template =
22579 FunctionTemplate::New(isolate);
22580 parent_template->SetHiddenPrototype(true);
22581 Local<v8::FunctionTemplate> function_template
22582 = FunctionTemplate::New(isolate);
22583 function_template->Inherit(parent_template);
22584 switch (signature_type) {
22585 case kNoSignature:
22586 break;
22587 case kSignatureOnReceiver:
22588 signature = v8::Signature::New(isolate, function_template);
22589 break;
22590 case kSignatureOnPrototype:
22591 signature = v8::Signature::New(isolate, parent_template);
22592 break;
22593 }
22594 signature_template = function_template->InstanceTemplate();
22595 }
22596 // Global object must pass checks.
22597 Local<v8::Context> context =
22598 v8::Context::New(isolate, NULL__null, signature_template);
22599 v8::Context::Scope context_scope(context);
22600 // Install regular object that can pass signature checks.
22601 Local<Object> function_receiver =
22602 signature_template->NewInstance(context).ToLocalChecked();
22603 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("function_receiver"), function_receiver) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22605, "Check failed: %s."
, "context->Global() ->Set(context, v8_str(\"function_receiver\"), function_receiver) .FromJust()"
); } } while (0)
22604 ->Set(context, v8_str("function_receiver"), function_receiver)do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("function_receiver"), function_receiver) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22605, "Check failed: %s."
, "context->Global() ->Set(context, v8_str(\"function_receiver\"), function_receiver) .FromJust()"
); } } while (0)
22605 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("function_receiver"), function_receiver) .FromJust
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 22605, "Check failed: %s."
, "context->Global() ->Set(context, v8_str(\"function_receiver\"), function_receiver) .FromJust()"
); } } while (0)
;
22606 // Get the holder objects.
22607 Local<Object> inner_global =
22608 Local<Object>::Cast(context->Global()->GetPrototype());
22609 // Install functions on hidden prototype object if there is one.
22610 data = Object::New(isolate);
22611 Local<FunctionTemplate> function_template = FunctionTemplate::New(
22612 isolate, OptimizationCallback, data, signature);
22613 Local<Function> function =
22614 function_template->GetFunction(context).ToLocalChecked();
22615 Local<Object> global_holder = inner_global;
22616 Local<Object> function_holder = function_receiver;
22617 if (signature_type == kSignatureOnPrototype) {
22618 function_holder = Local<Object>::Cast(function_holder->GetPrototype());
22619 global_holder = Local<Object>::Cast(global_holder->GetPrototype());
22620 }
22621 global_holder->Set(context, v8_str("g_f"), function).FromJust();
22622 global_holder->SetAccessorProperty(v8_str("g_acc"), function, function);
22623 function_holder->Set(context, v8_str("f"), function).FromJust();
22624 function_holder->SetAccessorProperty(v8_str("acc"), function, function);
22625 // Initialize expected values.
22626 callee = function;
22627 count = 0;
22628 if (global) {
22629 receiver = context->Global();
22630 holder = inner_global;
22631 } else {
22632 holder = function_receiver;
22633 // If not using a signature, add something else to the prototype chain
22634 // to test the case that holder != receiver
22635 if (signature_type == kNoSignature) {
22636 receiver = Local<Object>::Cast(CompileRun(
22637 "var receiver_subclass = {};\n"
22638 "receiver_subclass.__proto__ = function_receiver;\n"
22639 "receiver_subclass"));
22640 } else {
22641 receiver = Local<Object>::Cast(CompileRun(
22642 "var receiver_subclass = function_receiver;\n"
22643 "receiver_subclass"));
22644 }
22645 }
22646 // With no signature, the holder is not set.
22647 if (signature_type == kNoSignature) holder = receiver;
22648 // build wrap_function
22649 i::ScopedVector<char> wrap_function(200);
22650 if (global) {
22651 i::SNPrintF(
22652 wrap_function,
22653 "function wrap_f_%d() { var f = g_f; return f(); }\n"
22654 "function wrap_get_%d() { return this.g_acc; }\n"
22655 "function wrap_set_%d() { return this.g_acc = 1; }\n",
22656 key, key, key);
22657 } else {
22658 i::SNPrintF(
22659 wrap_function,
22660 "function wrap_f_%d() { return receiver_subclass.f(); }\n"
22661 "function wrap_get_%d() { return receiver_subclass.acc; }\n"
22662 "function wrap_set_%d() { return receiver_subclass.acc = 1; }\n",
22663 key, key, key);
22664 }
22665 // build source string
22666 i::ScopedVector<char> source(1000);
22667 i::SNPrintF(
22668 source,
22669 "%s\n" // wrap functions
22670 "function wrap_f() { return wrap_f_%d(); }\n"
22671 "function wrap_get() { return wrap_get_%d(); }\n"
22672 "function wrap_set() { return wrap_set_%d(); }\n"
22673 "check = function(returned) {\n"
22674 " if (returned !== 'returned') { throw returned; }\n"
22675 "}\n"
22676 "\n"
22677 "check(wrap_f());\n"
22678 "check(wrap_f());\n"
22679 "%%OptimizeFunctionOnNextCall(wrap_f_%d);\n"
22680 "check(wrap_f());\n"
22681 "\n"
22682 "check(wrap_get());\n"
22683 "check(wrap_get());\n"
22684 "%%OptimizeFunctionOnNextCall(wrap_get_%d);\n"
22685 "check(wrap_get());\n"
22686 "\n"
22687 "check = function(returned) {\n"
22688 " if (returned !== 1) { throw returned; }\n"
22689 "}\n"
22690 "check(wrap_set());\n"
22691 "check(wrap_set());\n"
22692 "%%OptimizeFunctionOnNextCall(wrap_set_%d);\n"
22693 "check(wrap_set());\n",
22694 wrap_function.start(), key, key, key, key, key, key);
22695 v8::TryCatch try_catch(isolate);
22696 CompileRun(source.start());
22697 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 22697, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
22698 CHECK_EQ(9, count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (9), (count
), "9" " " "==" " " "count")) { V8_Fatal("../test/cctest/test-api.cc"
, 22698, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
22699 }
22700};
22701
22702
22703Local<Object> ApiCallOptimizationChecker::data;
22704Local<Object> ApiCallOptimizationChecker::receiver;
22705Local<Object> ApiCallOptimizationChecker::holder;
22706Local<Object> ApiCallOptimizationChecker::callee;
22707int ApiCallOptimizationChecker::count = 0;
22708
22709
22710TEST(FunctionCallOptimization)static void TestFunctionCallOptimization(); CcTest register_test_FunctionCallOptimization
(TestFunctionCallOptimization, "../test/cctest/test-api.cc", "FunctionCallOptimization"
, __null, true, true); static void TestFunctionCallOptimization
()
{
22711 i::FLAG_allow_natives_syntax = true;
22712 ApiCallOptimizationChecker checker;
22713 checker.RunAll();
22714}
22715
22716
22717TEST(FunctionCallOptimizationMultipleArgs)static void TestFunctionCallOptimizationMultipleArgs(); CcTest
register_test_FunctionCallOptimizationMultipleArgs(TestFunctionCallOptimizationMultipleArgs
, "../test/cctest/test-api.cc", "FunctionCallOptimizationMultipleArgs"
, __null, true, true); static void TestFunctionCallOptimizationMultipleArgs
()
{
22718 i::FLAG_allow_natives_syntax = true;
22719 LocalContext context;
22720 v8::Isolate* isolate = context->GetIsolate();
22721 v8::HandleScope scope(isolate);
22722 Local<Object> global = context->Global();
22723 Local<v8::Function> function =
22724 Function::New(context.local(), Returns42).ToLocalChecked();
22725 global->Set(context.local(), v8_str("x"), function).FromJust();
22726 CompileRun(
22727 "function x_wrap() {\n"
22728 " for (var i = 0; i < 5; i++) {\n"
22729 " x(1,2,3);\n"
22730 " }\n"
22731 "}\n"
22732 "x_wrap();\n"
22733 "%OptimizeFunctionOnNextCall(x_wrap);"
22734 "x_wrap();\n");
22735}
22736
22737
22738static void ReturnsSymbolCallback(
22739 const v8::FunctionCallbackInfo<v8::Value>& info) {
22740 info.GetReturnValue().Set(v8::Symbol::New(info.GetIsolate()));
22741}
22742
22743
22744TEST(ApiCallbackCanReturnSymbols)static void TestApiCallbackCanReturnSymbols(); CcTest register_test_ApiCallbackCanReturnSymbols
(TestApiCallbackCanReturnSymbols, "../test/cctest/test-api.cc"
, "ApiCallbackCanReturnSymbols", __null, true, true); static void
TestApiCallbackCanReturnSymbols()
{
22745 i::FLAG_allow_natives_syntax = true;
22746 LocalContext context;
22747 v8::Isolate* isolate = context->GetIsolate();
22748 v8::HandleScope scope(isolate);
22749 Local<Object> global = context->Global();
22750 Local<v8::Function> function =
22751 Function::New(context.local(), ReturnsSymbolCallback).ToLocalChecked();
22752 global->Set(context.local(), v8_str("x"), function).FromJust();
22753 CompileRun(
22754 "function x_wrap() {\n"
22755 " for (var i = 0; i < 5; i++) {\n"
22756 " x();\n"
22757 " }\n"
22758 "}\n"
22759 "x_wrap();\n"
22760 "%OptimizeFunctionOnNextCall(x_wrap);"
22761 "x_wrap();\n");
22762}
22763
22764
22765TEST(EmptyApiCallback)static void TestEmptyApiCallback(); CcTest register_test_EmptyApiCallback
(TestEmptyApiCallback, "../test/cctest/test-api.cc", "EmptyApiCallback"
, __null, true, true); static void TestEmptyApiCallback()
{
22766 LocalContext context;
22767 auto isolate = context->GetIsolate();
22768 v8::HandleScope scope(isolate);
22769 auto global = context->Global();
22770 auto function = FunctionTemplate::New(isolate)
22771 ->GetFunction(context.local())
22772 .ToLocalChecked();
22773 global->Set(context.local(), v8_str("x"), function).FromJust();
22774
22775 auto result = CompileRun("x()");
22776 CHECK(v8::Utils::OpenHandle(*result)->IsJSGlobalProxy())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*result
)->IsJSGlobalProxy())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22776, "Check failed: %s.", "v8::Utils::OpenHandle(*result)->IsJSGlobalProxy()"
); } } while (0)
;
22777
22778 result = CompileRun("x(1,2,3)");
22779 CHECK(v8::Utils::OpenHandle(*result)->IsJSGlobalProxy())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*result
)->IsJSGlobalProxy())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22779, "Check failed: %s.", "v8::Utils::OpenHandle(*result)->IsJSGlobalProxy()"
); } } while (0)
;
22780
22781 result = CompileRun("x.call(undefined)");
22782 CHECK(v8::Utils::OpenHandle(*result)->IsJSGlobalProxy())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*result
)->IsJSGlobalProxy())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22782, "Check failed: %s.", "v8::Utils::OpenHandle(*result)->IsJSGlobalProxy()"
); } } while (0)
;
22783
22784 result = CompileRun("x.call(null)");
22785 CHECK(v8::Utils::OpenHandle(*result)->IsJSGlobalProxy())do { if ((__builtin_expect(!!(!(v8::Utils::OpenHandle(*result
)->IsJSGlobalProxy())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 22785, "Check failed: %s.", "v8::Utils::OpenHandle(*result)->IsJSGlobalProxy()"
); } } while (0)
;
22786
22787 result = CompileRun("7 + x.call(3) + 11");
22788 CHECK(result->IsInt32())do { if ((__builtin_expect(!!(!(result->IsInt32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 22788, "Check failed: %s."
, "result->IsInt32()"); } } while (0)
;
22789 CHECK_EQ(21, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (21), (
result->Int32Value(context.local()).FromJust()), "21" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 22789, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
22790
22791 result = CompileRun("7 + x.call(3, 101, 102, 103, 104) + 11");
22792 CHECK(result->IsInt32())do { if ((__builtin_expect(!!(!(result->IsInt32())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 22792, "Check failed: %s."
, "result->IsInt32()"); } } while (0)
;
22793 CHECK_EQ(21, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (21), (
result->Int32Value(context.local()).FromJust()), "21" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 22793, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
22794
22795 result = CompileRun("var y = []; x.call(y)");
22796 CHECK(result->IsArray())do { if ((__builtin_expect(!!(!(result->IsArray())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 22796, "Check failed: %s."
, "result->IsArray()"); } } while (0)
;
22797
22798 result = CompileRun("x.call(y, 1, 2, 3, 4)");
22799 CHECK(result->IsArray())do { if ((__builtin_expect(!!(!(result->IsArray())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 22799, "Check failed: %s."
, "result->IsArray()"); } } while (0)
;
22800}
22801
22802
22803TEST(SimpleSignatureCheck)static void TestSimpleSignatureCheck(); CcTest register_test_SimpleSignatureCheck
(TestSimpleSignatureCheck, "../test/cctest/test-api.cc", "SimpleSignatureCheck"
, __null, true, true); static void TestSimpleSignatureCheck()
{
22804 LocalContext context;
22805 auto isolate = context->GetIsolate();
22806 v8::HandleScope scope(isolate);
22807 auto global = context->Global();
22808 auto sig_obj = FunctionTemplate::New(isolate);
22809 auto sig = v8::Signature::New(isolate, sig_obj);
22810 auto x = FunctionTemplate::New(isolate, Returns42, Local<Value>(), sig);
22811 global->Set(context.local(), v8_str("sig_obj"),
22812 sig_obj->GetFunction(context.local()).ToLocalChecked())
22813 .FromJust();
22814 global->Set(context.local(), v8_str("x"),
22815 x->GetFunction(context.local()).ToLocalChecked())
22816 .FromJust();
22817 CompileRun("var s = new sig_obj();");
22818 {
22819 TryCatch try_catch(isolate);
22820 CompileRun("x()");
22821 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22821, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
22822 }
22823 {
22824 TryCatch try_catch(isolate);
22825 CompileRun("x.call(1)");
22826 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22826, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
22827 }
22828 {
22829 TryCatch try_catch(isolate);
22830 auto result = CompileRun("s.x = x; s.x()");
22831 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 22831, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
22832 CHECK_EQ(42, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 22832, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
22833 }
22834 {
22835 TryCatch try_catch(isolate);
22836 auto result = CompileRun("x.call(s)");
22837 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 22837, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
22838 CHECK_EQ(42, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 22838, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
22839 }
22840}
22841
22842
22843TEST(ChainSignatureCheck)static void TestChainSignatureCheck(); CcTest register_test_ChainSignatureCheck
(TestChainSignatureCheck, "../test/cctest/test-api.cc", "ChainSignatureCheck"
, __null, true, true); static void TestChainSignatureCheck()
{
22844 LocalContext context;
22845 auto isolate = context->GetIsolate();
22846 v8::HandleScope scope(isolate);
22847 auto global = context->Global();
22848 auto sig_obj = FunctionTemplate::New(isolate);
22849 auto sig = v8::Signature::New(isolate, sig_obj);
22850 for (int i = 0; i < 4; ++i) {
22851 auto temp = FunctionTemplate::New(isolate);
22852 temp->Inherit(sig_obj);
22853 sig_obj = temp;
22854 }
22855 auto x = FunctionTemplate::New(isolate, Returns42, Local<Value>(), sig);
22856 global->Set(context.local(), v8_str("sig_obj"),
22857 sig_obj->GetFunction(context.local()).ToLocalChecked())
22858 .FromJust();
22859 global->Set(context.local(), v8_str("x"),
22860 x->GetFunction(context.local()).ToLocalChecked())
22861 .FromJust();
22862 CompileRun("var s = new sig_obj();");
22863 {
22864 TryCatch try_catch(isolate);
22865 CompileRun("x()");
22866 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22866, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
22867 }
22868 {
22869 TryCatch try_catch(isolate);
22870 CompileRun("x.call(1)");
22871 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22871, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
22872 }
22873 {
22874 TryCatch try_catch(isolate);
22875 auto result = CompileRun("s.x = x; s.x()");
22876 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 22876, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
22877 CHECK_EQ(42, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 22877, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
22878 }
22879 {
22880 TryCatch try_catch(isolate);
22881 auto result = CompileRun("x.call(s)");
22882 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 22882, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
22883 CHECK_EQ(42, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 22883, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
22884 }
22885}
22886
22887
22888TEST(PrototypeSignatureCheck)static void TestPrototypeSignatureCheck(); CcTest register_test_PrototypeSignatureCheck
(TestPrototypeSignatureCheck, "../test/cctest/test-api.cc", "PrototypeSignatureCheck"
, __null, true, true); static void TestPrototypeSignatureCheck
()
{
22889 LocalContext context;
22890 auto isolate = context->GetIsolate();
22891 v8::HandleScope scope(isolate);
22892 auto global = context->Global();
22893 auto sig_obj = FunctionTemplate::New(isolate);
22894 sig_obj->SetHiddenPrototype(true);
22895 auto sig = v8::Signature::New(isolate, sig_obj);
22896 auto x = FunctionTemplate::New(isolate, Returns42, Local<Value>(), sig);
22897 global->Set(context.local(), v8_str("sig_obj"),
22898 sig_obj->GetFunction(context.local()).ToLocalChecked())
22899 .FromJust();
22900 global->Set(context.local(), v8_str("x"),
22901 x->GetFunction(context.local()).ToLocalChecked())
22902 .FromJust();
22903 CompileRun("s = {}; s.__proto__ = new sig_obj();");
22904 {
22905 TryCatch try_catch(isolate);
22906 CompileRun("x()");
22907 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22907, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
22908 }
22909 {
22910 TryCatch try_catch(isolate);
22911 CompileRun("x.call(1)");
22912 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 22912, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
22913 }
22914 {
22915 TryCatch try_catch(isolate);
22916 auto result = CompileRun("s.x = x; s.x()");
22917 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 22917, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
22918 CHECK_EQ(42, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 22918, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
22919 }
22920 {
22921 TryCatch try_catch(isolate);
22922 auto result = CompileRun("x.call(s)");
22923 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 22923, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
22924 CHECK_EQ(42, result->Int32Value(context.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
result->Int32Value(context.local()).FromJust()), "42" " " "=="
" " "result->Int32Value(context.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 22924, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
22925 }
22926}
22927
22928
22929static const char* last_event_message;
22930static int last_event_status;
22931void StoringEventLoggerCallback(const char* message, int status) {
22932 last_event_message = message;
22933 last_event_status = status;
22934}
22935
22936
22937TEST(EventLogging)static void TestEventLogging(); CcTest register_test_EventLogging
(TestEventLogging, "../test/cctest/test-api.cc", "EventLogging"
, __null, true, true); static void TestEventLogging()
{
22938 v8::Isolate* isolate = CcTest::isolate();
22939 isolate->SetEventLogger(StoringEventLoggerCallback);
22940 v8::internal::HistogramTimer histogramTimer(
22941 "V8.Test", 0, 10000, v8::internal::HistogramTimer::MILLISECOND, 50,
22942 reinterpret_cast<v8::internal::Isolate*>(isolate));
22943 histogramTimer.Start();
22944 CHECK_EQ(0, strcmp("V8.Test", last_event_message))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("V8.Test", last_event_message)), "0" " " "==" " " "strcmp(\"V8.Test\", last_event_message)"
)) { V8_Fatal("../test/cctest/test-api.cc", 22944, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
22945 CHECK_EQ(0, last_event_status)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (last_event_status
), "0" " " "==" " " "last_event_status")) { V8_Fatal("../test/cctest/test-api.cc"
, 22945, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
22946 histogramTimer.Stop();
22947 CHECK_EQ(0, strcmp("V8.Test", last_event_message))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
("V8.Test", last_event_message)), "0" " " "==" " " "strcmp(\"V8.Test\", last_event_message)"
)) { V8_Fatal("../test/cctest/test-api.cc", 22947, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
22948 CHECK_EQ(1, last_event_status)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (last_event_status
), "1" " " "==" " " "last_event_status")) { V8_Fatal("../test/cctest/test-api.cc"
, 22948, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
22949}
22950
22951
22952TEST(Promises)static void TestPromises(); CcTest register_test_Promises(TestPromises
, "../test/cctest/test-api.cc", "Promises", __null, true, true
); static void TestPromises()
{
22953 LocalContext context;
22954 v8::Isolate* isolate = context->GetIsolate();
22955 v8::HandleScope scope(isolate);
22956
22957 // Creation.
22958 Local<v8::Promise::Resolver> pr =
22959 v8::Promise::Resolver::New(context.local()).ToLocalChecked();
22960 Local<v8::Promise::Resolver> rr =
22961 v8::Promise::Resolver::New(context.local()).ToLocalChecked();
22962 Local<v8::Promise> p = pr->GetPromise();
22963 Local<v8::Promise> r = rr->GetPromise();
22964
22965 // IsPromise predicate.
22966 CHECK(p->IsPromise())do { if ((__builtin_expect(!!(!(p->IsPromise())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22966, "Check failed: %s.", "p->IsPromise()"
); } } while (0)
;
22967 CHECK(r->IsPromise())do { if ((__builtin_expect(!!(!(r->IsPromise())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22967, "Check failed: %s.", "r->IsPromise()"
); } } while (0)
;
22968 Local<Value> o = v8::Object::New(isolate);
22969 CHECK(!o->IsPromise())do { if ((__builtin_expect(!!(!(!o->IsPromise())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22969, "Check failed: %s.", "!o->IsPromise()"
); } } while (0)
;
22970
22971 // Resolution and rejection.
22972 pr->Resolve(context.local(), v8::Integer::New(isolate, 1)).FromJust();
22973 CHECK(p->IsPromise())do { if ((__builtin_expect(!!(!(p->IsPromise())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22973, "Check failed: %s.", "p->IsPromise()"
); } } while (0)
;
22974 rr->Reject(context.local(), v8::Integer::New(isolate, 2)).FromJust();
22975 CHECK(r->IsPromise())do { if ((__builtin_expect(!!(!(r->IsPromise())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22975, "Check failed: %s.", "r->IsPromise()"
); } } while (0)
;
22976}
22977
22978
22979TEST(PromiseThen)static void TestPromiseThen(); CcTest register_test_PromiseThen
(TestPromiseThen, "../test/cctest/test-api.cc", "PromiseThen"
, __null, true, true); static void TestPromiseThen()
{
22980 LocalContext context;
22981 v8::Isolate* isolate = context->GetIsolate();
22982 v8::HandleScope scope(isolate);
22983 Local<Object> global = context->Global();
22984
22985 // Creation.
22986 Local<v8::Promise::Resolver> pr =
22987 v8::Promise::Resolver::New(context.local()).ToLocalChecked();
22988 Local<v8::Promise::Resolver> qr =
22989 v8::Promise::Resolver::New(context.local()).ToLocalChecked();
22990 Local<v8::Promise> p = pr->GetPromise();
22991 Local<v8::Promise> q = qr->GetPromise();
22992
22993 CHECK(p->IsPromise())do { if ((__builtin_expect(!!(!(p->IsPromise())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22993, "Check failed: %s.", "p->IsPromise()"
); } } while (0)
;
22994 CHECK(q->IsPromise())do { if ((__builtin_expect(!!(!(q->IsPromise())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 22994, "Check failed: %s.", "q->IsPromise()"
); } } while (0)
;
22995
22996 pr->Resolve(context.local(), v8::Integer::New(isolate, 1)).FromJust();
22997 qr->Resolve(context.local(), p).FromJust();
22998
22999 // Chaining non-pending promises.
23000 CompileRun(
23001 "var x1 = 0;\n"
23002 "var x2 = 0;\n"
23003 "function f1(x) { x1 = x; return x+1 };\n"
23004 "function f2(x) { x2 = x; return x+1 };\n");
23005 Local<Function> f1 = Local<Function>::Cast(
23006 global->Get(context.local(), v8_str("f1")).ToLocalChecked());
23007 Local<Function> f2 = Local<Function>::Cast(
23008 global->Get(context.local(), v8_str("f2")).ToLocalChecked());
23009
23010 // Then
23011 CompileRun("x1 = x2 = 0;");
23012 q->Then(context.local(), f1).ToLocalChecked();
23013 CHECK_EQ(0, global->Get(context.local(), v8_str("x1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23016, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23014 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23016, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23015 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23016, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23016 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23016, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23017 isolate->RunMicrotasks();
23018 CHECK_EQ(1, global->Get(context.local(), v8_str("x1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23021, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23019 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23021, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23020 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23021, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23021 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "1" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23021, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23022
23023 // Then
23024 CompileRun("x1 = x2 = 0;");
23025 pr = v8::Promise::Resolver::New(context.local()).ToLocalChecked();
23026 qr = v8::Promise::Resolver::New(context.local()).ToLocalChecked();
23027
23028 qr->Resolve(context.local(), pr).FromJust();
23029 qr->GetPromise()
23030 ->Then(context.local(), f1)
23031 .ToLocalChecked()
23032 ->Then(context.local(), f2)
23033 .ToLocalChecked();
23034
23035 CHECK_EQ(0, global->Get(context.local(), v8_str("x1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23038, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23036 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23038, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23037 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23038, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23038 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23038, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23039 CHECK_EQ(0, global->Get(context.local(), v8_str("x2"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23042, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23040 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23042, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23041 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23042, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23042 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23042, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23043 isolate->RunMicrotasks();
23044 CHECK_EQ(0, global->Get(context.local(), v8_str("x1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23047, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23045 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23047, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23046 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23047, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23047 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23047, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23048 CHECK_EQ(0, global->Get(context.local(), v8_str("x2"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23051, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23049 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23051, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23050 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23051, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23051 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23051, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23052
23053 pr->Resolve(context.local(), v8::Integer::New(isolate, 3)).FromJust();
23054
23055 CHECK_EQ(0, global->Get(context.local(), v8_str("x1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23056 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23057 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23058 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23058, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23059 CHECK_EQ(0, global->Get(context.local(), v8_str("x2"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23060 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23061 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23062 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "0" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23062, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23063 isolate->RunMicrotasks();
23064 CHECK_EQ(3, global->Get(context.local(), v8_str("x1"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23067, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23065 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23067, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23066 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23067, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23067 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (global
->Get(context.local(), v8_str("x1")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "3" " " "==" " " "global->Get(context.local(), v8_str(\"x1\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23067, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23068 CHECK_EQ(4, global->Get(context.local(), v8_str("x2"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "4" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23071, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23069 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "4" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23071, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23070 ->Int32Value(context.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "4" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23071, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23071 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (global
->Get(context.local(), v8_str("x2")) .ToLocalChecked() ->
Int32Value(context.local()) .FromJust()), "4" " " "==" " " "global->Get(context.local(), v8_str(\"x2\")) .ToLocalChecked() ->Int32Value(context.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23071, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23072}
23073
23074
23075TEST(DisallowJavascriptExecutionScope)static void TestDisallowJavascriptExecutionScope(); CcTest register_test_DisallowJavascriptExecutionScope
(TestDisallowJavascriptExecutionScope, "../test/cctest/test-api.cc"
, "DisallowJavascriptExecutionScope", __null, true, true); static
void TestDisallowJavascriptExecutionScope()
{
23076 LocalContext context;
23077 v8::Isolate* isolate = context->GetIsolate();
23078 v8::HandleScope scope(isolate);
23079 v8::Isolate::DisallowJavascriptExecutionScope no_js(
23080 isolate, v8::Isolate::DisallowJavascriptExecutionScope::CRASH_ON_FAILURE);
23081 CompileRun("2+2");
23082}
23083
23084
23085TEST(AllowJavascriptExecutionScope)static void TestAllowJavascriptExecutionScope(); CcTest register_test_AllowJavascriptExecutionScope
(TestAllowJavascriptExecutionScope, "../test/cctest/test-api.cc"
, "AllowJavascriptExecutionScope", __null, true, true); static
void TestAllowJavascriptExecutionScope()
{
23086 LocalContext context;
23087 v8::Isolate* isolate = context->GetIsolate();
23088 v8::HandleScope scope(isolate);
23089 v8::Isolate::DisallowJavascriptExecutionScope no_js(
23090 isolate, v8::Isolate::DisallowJavascriptExecutionScope::CRASH_ON_FAILURE);
23091 v8::Isolate::DisallowJavascriptExecutionScope throw_js(
23092 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
23093 { v8::Isolate::AllowJavascriptExecutionScope yes_js(isolate);
23094 CompileRun("1+1");
23095 }
23096}
23097
23098
23099TEST(ThrowOnJavascriptExecution)static void TestThrowOnJavascriptExecution(); CcTest register_test_ThrowOnJavascriptExecution
(TestThrowOnJavascriptExecution, "../test/cctest/test-api.cc"
, "ThrowOnJavascriptExecution", __null, true, true); static void
TestThrowOnJavascriptExecution()
{
23100 LocalContext context;
23101 v8::Isolate* isolate = context->GetIsolate();
23102 v8::HandleScope scope(isolate);
23103 v8::TryCatch try_catch(isolate);
23104 v8::Isolate::DisallowJavascriptExecutionScope throw_js(
23105 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
23106 CompileRun("1+1");
23107 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 23107, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
23108}
23109
23110
23111TEST(Regress354123)static void TestRegress354123(); CcTest register_test_Regress354123
(TestRegress354123, "../test/cctest/test-api.cc", "Regress354123"
, __null, true, true); static void TestRegress354123()
{
23112 LocalContext current;
23113 v8::Isolate* isolate = current->GetIsolate();
23114 v8::HandleScope scope(isolate);
23115
23116 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
23117 templ->SetAccessCheckCallback(AccessCounter);
23118 CHECK(current->Global()do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("friend"), templ->NewInstance(current
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23121, "Check failed: %s.", "current->Global() ->Set(current.local(), v8_str(\"friend\"), templ->NewInstance(current.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
23119 ->Set(current.local(), v8_str("friend"),do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("friend"), templ->NewInstance(current
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23121, "Check failed: %s.", "current->Global() ->Set(current.local(), v8_str(\"friend\"), templ->NewInstance(current.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
23120 templ->NewInstance(current.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("friend"), templ->NewInstance(current
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23121, "Check failed: %s.", "current->Global() ->Set(current.local(), v8_str(\"friend\"), templ->NewInstance(current.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
23121 .FromJust())do { if ((__builtin_expect(!!(!(current->Global() ->Set
(current.local(), v8_str("friend"), templ->NewInstance(current
.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23121, "Check failed: %s.", "current->Global() ->Set(current.local(), v8_str(\"friend\"), templ->NewInstance(current.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
23122
23123 // Test access using __proto__ from the prototype chain.
23124 access_count = 0;
23125 CompileRun("friend.__proto__ = {};");
23126 CHECK_EQ(2, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (access_count
), "2" " " "==" " " "access_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 23126, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23127 CompileRun("friend.__proto__;");
23128 CHECK_EQ(4, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (access_count
), "4" " " "==" " " "access_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 23128, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23129
23130 // Test access using __proto__ as a hijacked function (A).
23131 access_count = 0;
23132 CompileRun("var p = Object.prototype;"
23133 "var f = Object.getOwnPropertyDescriptor(p, '__proto__').set;"
23134 "f.call(friend, {});");
23135 CHECK_EQ(1, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (access_count
), "1" " " "==" " " "access_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 23135, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23136 CompileRun("var p = Object.prototype;"
23137 "var f = Object.getOwnPropertyDescriptor(p, '__proto__').get;"
23138 "f.call(friend);");
23139 CHECK_EQ(2, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (access_count
), "2" " " "==" " " "access_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 23139, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23140
23141 // Test access using __proto__ as a hijacked function (B).
23142 access_count = 0;
23143 CompileRun("var f = Object.prototype.__lookupSetter__('__proto__');"
23144 "f.call(friend, {});");
23145 CHECK_EQ(1, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (access_count
), "1" " " "==" " " "access_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 23145, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23146 CompileRun("var f = Object.prototype.__lookupGetter__('__proto__');"
23147 "f.call(friend);");
23148 CHECK_EQ(2, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (access_count
), "2" " " "==" " " "access_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 23148, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23149
23150 // Test access using Object.setPrototypeOf reflective method.
23151 access_count = 0;
23152 CompileRun("Object.setPrototypeOf(friend, {});");
23153 CHECK_EQ(1, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (access_count
), "1" " " "==" " " "access_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 23153, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23154 CompileRun("Object.getPrototypeOf(friend);");
23155 CHECK_EQ(2, access_count)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (access_count
), "2" " " "==" " " "access_count")) { V8_Fatal("../test/cctest/test-api.cc"
, 23155, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23156}
23157
23158
23159TEST(CaptureStackTraceForStackOverflow)static void TestCaptureStackTraceForStackOverflow(); CcTest register_test_CaptureStackTraceForStackOverflow
(TestCaptureStackTraceForStackOverflow, "../test/cctest/test-api.cc"
, "CaptureStackTraceForStackOverflow", __null, true, true); static
void TestCaptureStackTraceForStackOverflow()
{
23160 v8::internal::FLAG_stack_size = 150;
23161 LocalContext current;
23162 v8::Isolate* isolate = current->GetIsolate();
23163 v8::HandleScope scope(isolate);
23164 isolate->SetCaptureStackTraceForUncaughtExceptions(true, 10,
23165 v8::StackTrace::kDetailed);
23166 v8::TryCatch try_catch(isolate);
23167 CompileRun("(function f(x) { f(x+1); })(0)");
23168 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 23168, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
23169}
23170
23171
23172TEST(ScriptNameAndLineNumber)static void TestScriptNameAndLineNumber(); CcTest register_test_ScriptNameAndLineNumber
(TestScriptNameAndLineNumber, "../test/cctest/test-api.cc", "ScriptNameAndLineNumber"
, __null, true, true); static void TestScriptNameAndLineNumber
()
{
23173 LocalContext env;
23174 v8::Isolate* isolate = env->GetIsolate();
23175 v8::HandleScope scope(isolate);
23176 const char* url = "http://www.foo.com/foo.js";
23177 v8::ScriptOrigin origin(v8_str(url), v8::Integer::New(isolate, 13));
23178 v8::ScriptCompiler::Source script_source(v8_str("var foo;"), origin);
23179 Local<Script> script =
23180 v8::ScriptCompiler::Compile(env.local(), &script_source).ToLocalChecked();
23181 Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
23182 CHECK(!script_name.IsEmpty())do { if ((__builtin_expect(!!(!(!script_name.IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 23182, "Check failed: %s."
, "!script_name.IsEmpty()"); } } while (0)
;
23183 CHECK(script_name->IsString())do { if ((__builtin_expect(!!(!(script_name->IsString())),
0))) { V8_Fatal("../test/cctest/test-api.cc", 23183, "Check failed: %s."
, "script_name->IsString()"); } } while (0)
;
23184 String::Utf8Value utf8_name(script_name);
23185 CHECK_EQ(0, strcmp(url, *utf8_name))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(url, *utf8_name)), "0" " " "==" " " "strcmp(url, *utf8_name)"
)) { V8_Fatal("../test/cctest/test-api.cc", 23185, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23186 int line_number = script->GetUnboundScript()->GetLineNumber(0);
23187 CHECK_EQ(13, line_number)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
line_number), "13" " " "==" " " "line_number")) { V8_Fatal("../test/cctest/test-api.cc"
, 23187, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
23188}
23189
23190void CheckMagicComments(Local<Script> script, const char* expected_source_url,
23191 const char* expected_source_mapping_url) {
23192 if (expected_source_url != NULL__null) {
23193 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL());
23194 CHECK_EQ(0, strcmp(expected_source_url, *url))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(expected_source_url, *url)), "0" " " "==" " " "strcmp(expected_source_url, *url)"
)) { V8_Fatal("../test/cctest/test-api.cc", 23194, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23195 } else {
23196 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined())do { if ((__builtin_expect(!!(!(script->GetUnboundScript()
->GetSourceURL()->IsUndefined())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23196, "Check failed: %s.", "script->GetUnboundScript()->GetSourceURL()->IsUndefined()"
); } } while (0)
;
23197 }
23198 if (expected_source_mapping_url != NULL__null) {
23199 v8::String::Utf8Value url(
23200 script->GetUnboundScript()->GetSourceMappingURL());
23201 CHECK_EQ(0, strcmp(expected_source_mapping_url, *url))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(expected_source_mapping_url, *url)), "0" " " "==" " " "strcmp(expected_source_mapping_url, *url)"
)) { V8_Fatal("../test/cctest/test-api.cc", 23201, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23202 } else {
23203 CHECK(script->GetUnboundScript()->GetSourceMappingURL()->IsUndefined())do { if ((__builtin_expect(!!(!(script->GetUnboundScript()
->GetSourceMappingURL()->IsUndefined())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 23203, "Check failed: %s.", "script->GetUnboundScript()->GetSourceMappingURL()->IsUndefined()"
); } } while (0)
;
23204 }
23205}
23206
23207void SourceURLHelper(const char* source, const char* expected_source_url,
23208 const char* expected_source_mapping_url) {
23209 Local<Script> script = v8_compile(source);
23210 CheckMagicComments(script, expected_source_url, expected_source_mapping_url);
23211}
23212
23213
23214TEST(ScriptSourceURLAndSourceMappingURL)static void TestScriptSourceURLAndSourceMappingURL(); CcTest register_test_ScriptSourceURLAndSourceMappingURL
(TestScriptSourceURLAndSourceMappingURL, "../test/cctest/test-api.cc"
, "ScriptSourceURLAndSourceMappingURL", __null, true, true); static
void TestScriptSourceURLAndSourceMappingURL()
{
23215 LocalContext env;
23216 v8::Isolate* isolate = env->GetIsolate();
23217 v8::HandleScope scope(isolate);
23218 SourceURLHelper("function foo() {}\n"
23219 "//# sourceURL=bar1.js\n", "bar1.js", NULL__null);
23220 SourceURLHelper("function foo() {}\n"
23221 "//# sourceMappingURL=bar2.js\n", NULL__null, "bar2.js");
23222
23223 // Both sourceURL and sourceMappingURL.
23224 SourceURLHelper("function foo() {}\n"
23225 "//# sourceURL=bar3.js\n"
23226 "//# sourceMappingURL=bar4.js\n", "bar3.js", "bar4.js");
23227
23228 // Two source URLs; the first one is ignored.
23229 SourceURLHelper("function foo() {}\n"
23230 "//# sourceURL=ignoreme.js\n"
23231 "//# sourceURL=bar5.js\n", "bar5.js", NULL__null);
23232 SourceURLHelper("function foo() {}\n"
23233 "//# sourceMappingURL=ignoreme.js\n"
23234 "//# sourceMappingURL=bar6.js\n", NULL__null, "bar6.js");
23235
23236 // SourceURL or sourceMappingURL in the middle of the script.
23237 SourceURLHelper("function foo() {}\n"
23238 "//# sourceURL=bar7.js\n"
23239 "function baz() {}\n", "bar7.js", NULL__null);
23240 SourceURLHelper("function foo() {}\n"
23241 "//# sourceMappingURL=bar8.js\n"
23242 "function baz() {}\n", NULL__null, "bar8.js");
23243
23244 // Too much whitespace.
23245 SourceURLHelper("function foo() {}\n"
23246 "//# sourceURL=bar9.js\n"
23247 "//# sourceMappingURL=bar10.js\n", NULL__null, NULL__null);
23248 SourceURLHelper("function foo() {}\n"
23249 "//# sourceURL =bar11.js\n"
23250 "//# sourceMappingURL =bar12.js\n", NULL__null, NULL__null);
23251
23252 // Disallowed characters in value.
23253 SourceURLHelper("function foo() {}\n"
23254 "//# sourceURL=bar13 .js \n"
23255 "//# sourceMappingURL=bar14 .js \n",
23256 NULL__null, NULL__null);
23257 SourceURLHelper("function foo() {}\n"
23258 "//# sourceURL=bar15\t.js \n"
23259 "//# sourceMappingURL=bar16\t.js \n",
23260 NULL__null, NULL__null);
23261 SourceURLHelper("function foo() {}\n"
23262 "//# sourceURL=bar17'.js \n"
23263 "//# sourceMappingURL=bar18'.js \n",
23264 NULL__null, NULL__null);
23265 SourceURLHelper("function foo() {}\n"
23266 "//# sourceURL=bar19\".js \n"
23267 "//# sourceMappingURL=bar20\".js \n",
23268 NULL__null, NULL__null);
23269
23270 // Not too much whitespace.
23271 SourceURLHelper("function foo() {}\n"
23272 "//# sourceURL= bar21.js \n"
23273 "//# sourceMappingURL= bar22.js \n", "bar21.js", "bar22.js");
23274}
23275
23276
23277TEST(GetOwnPropertyDescriptor)static void TestGetOwnPropertyDescriptor(); CcTest register_test_GetOwnPropertyDescriptor
(TestGetOwnPropertyDescriptor, "../test/cctest/test-api.cc", "GetOwnPropertyDescriptor"
, __null, true, true); static void TestGetOwnPropertyDescriptor
()
{
23278 LocalContext env;
23279 v8::Isolate* isolate = env->GetIsolate();
23280 v8::HandleScope scope(isolate);
23281 CompileRun(
23282 "var x = { value : 13};"
23283 "Object.defineProperty(x, 'p0', {value : 12});"
23284 "Object.defineProperty(x, 'p1', {"
23285 " set : function(value) { this.value = value; },"
23286 " get : function() { return this.value; },"
23287 "});");
23288 Local<Object> x = Local<Object>::Cast(
23289 env->Global()->Get(env.local(), v8_str("x")).ToLocalChecked());
23290 Local<Value> desc =
23291 x->GetOwnPropertyDescriptor(env.local(), v8_str("no_prop"))
23292 .ToLocalChecked();
23293 CHECK(desc->IsUndefined())do { if ((__builtin_expect(!!(!(desc->IsUndefined())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 23293, "Check failed: %s."
, "desc->IsUndefined()"); } } while (0)
;
23294 desc =
23295 x->GetOwnPropertyDescriptor(env.local(), v8_str("p0")).ToLocalChecked();
23296 CHECK(v8_num(12)do { if ((__builtin_expect(!!(!(v8_num(12) ->Equals(env.local
(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str
("value")) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 23300, "Check failed: %s.", "v8_num(12) ->Equals(env.local(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str(\"value\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
23297 ->Equals(env.local(), Local<Object>::Cast(desc)do { if ((__builtin_expect(!!(!(v8_num(12) ->Equals(env.local
(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str
("value")) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 23300, "Check failed: %s.", "v8_num(12) ->Equals(env.local(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str(\"value\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
23298 ->Get(env.local(), v8_str("value"))do { if ((__builtin_expect(!!(!(v8_num(12) ->Equals(env.local
(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str
("value")) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 23300, "Check failed: %s.", "v8_num(12) ->Equals(env.local(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str(\"value\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
23299 .ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_num(12) ->Equals(env.local
(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str
("value")) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 23300, "Check failed: %s.", "v8_num(12) ->Equals(env.local(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str(\"value\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
23300 .FromJust())do { if ((__builtin_expect(!!(!(v8_num(12) ->Equals(env.local
(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str
("value")) .ToLocalChecked()) .FromJust())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 23300, "Check failed: %s.", "v8_num(12) ->Equals(env.local(), Local<Object>::Cast(desc) ->Get(env.local(), v8_str(\"value\")) .ToLocalChecked()) .FromJust()"
); } } while (0)
;
23301 desc =
23302 x->GetOwnPropertyDescriptor(env.local(), v8_str("p1")).ToLocalChecked();
23303 Local<Function> set =
23304 Local<Function>::Cast(Local<Object>::Cast(desc)
23305 ->Get(env.local(), v8_str("set"))
23306 .ToLocalChecked());
23307 Local<Function> get =
23308 Local<Function>::Cast(Local<Object>::Cast(desc)
23309 ->Get(env.local(), v8_str("get"))
23310 .ToLocalChecked());
23311 CHECK(v8_num(13)do { if ((__builtin_expect(!!(!(v8_num(13) ->Equals(env.local
(), get->Call(env.local(), x, 0, __null).ToLocalChecked())
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
23314, "Check failed: %s.", "v8_num(13) ->Equals(env.local(), get->Call(env.local(), x, 0, NULL).ToLocalChecked()) .FromJust()"
); } } while (0)
23312 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8_num(13) ->Equals(env.local
(), get->Call(env.local(), x, 0, __null).ToLocalChecked())
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
23314, "Check failed: %s.", "v8_num(13) ->Equals(env.local(), get->Call(env.local(), x, 0, NULL).ToLocalChecked()) .FromJust()"
); } } while (0)
23313 get->Call(env.local(), x, 0, NULL).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_num(13) ->Equals(env.local
(), get->Call(env.local(), x, 0, __null).ToLocalChecked())
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
23314, "Check failed: %s.", "v8_num(13) ->Equals(env.local(), get->Call(env.local(), x, 0, NULL).ToLocalChecked()) .FromJust()"
); } } while (0)
23314 .FromJust())do { if ((__builtin_expect(!!(!(v8_num(13) ->Equals(env.local
(), get->Call(env.local(), x, 0, __null).ToLocalChecked())
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
23314, "Check failed: %s.", "v8_num(13) ->Equals(env.local(), get->Call(env.local(), x, 0, NULL).ToLocalChecked()) .FromJust()"
); } } while (0)
;
23315 Local<Value> args[] = {v8_num(14)};
23316 set->Call(env.local(), x, 1, args).ToLocalChecked();
23317 CHECK(v8_num(14)do { if ((__builtin_expect(!!(!(v8_num(14) ->Equals(env.local
(), get->Call(env.local(), x, 0, __null).ToLocalChecked())
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
23320, "Check failed: %s.", "v8_num(14) ->Equals(env.local(), get->Call(env.local(), x, 0, NULL).ToLocalChecked()) .FromJust()"
); } } while (0)
23318 ->Equals(env.local(),do { if ((__builtin_expect(!!(!(v8_num(14) ->Equals(env.local
(), get->Call(env.local(), x, 0, __null).ToLocalChecked())
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
23320, "Check failed: %s.", "v8_num(14) ->Equals(env.local(), get->Call(env.local(), x, 0, NULL).ToLocalChecked()) .FromJust()"
); } } while (0)
23319 get->Call(env.local(), x, 0, NULL).ToLocalChecked())do { if ((__builtin_expect(!!(!(v8_num(14) ->Equals(env.local
(), get->Call(env.local(), x, 0, __null).ToLocalChecked())
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
23320, "Check failed: %s.", "v8_num(14) ->Equals(env.local(), get->Call(env.local(), x, 0, NULL).ToLocalChecked()) .FromJust()"
); } } while (0)
23320 .FromJust())do { if ((__builtin_expect(!!(!(v8_num(14) ->Equals(env.local
(), get->Call(env.local(), x, 0, __null).ToLocalChecked())
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
23320, "Check failed: %s.", "v8_num(14) ->Equals(env.local(), get->Call(env.local(), x, 0, NULL).ToLocalChecked()) .FromJust()"
); } } while (0)
;
23321}
23322
23323
23324TEST(Regress411877)static void TestRegress411877(); CcTest register_test_Regress411877
(TestRegress411877, "../test/cctest/test-api.cc", "Regress411877"
, __null, true, true); static void TestRegress411877()
{
23325 v8::Isolate* isolate = CcTest::isolate();
23326 v8::HandleScope handle_scope(isolate);
23327 v8::Local<v8::ObjectTemplate> object_template =
23328 v8::ObjectTemplate::New(isolate);
23329 object_template->SetAccessCheckCallback(AccessCounter);
23330
23331 v8::Local<Context> context = Context::New(isolate);
23332 v8::Context::Scope context_scope(context);
23333
23334 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("o"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23337, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"o\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
23335 ->Set(context, v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("o"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23337, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"o\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
23336 object_template->NewInstance(context).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("o"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23337, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"o\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
23337 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("o"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23337, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"o\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
;
23338 CompileRun("Object.getOwnPropertyNames(o)");
23339}
23340
23341
23342TEST(GetHiddenPropertyTableAfterAccessCheck)static void TestGetHiddenPropertyTableAfterAccessCheck(); CcTest
register_test_GetHiddenPropertyTableAfterAccessCheck(TestGetHiddenPropertyTableAfterAccessCheck
, "../test/cctest/test-api.cc", "GetHiddenPropertyTableAfterAccessCheck"
, __null, true, true); static void TestGetHiddenPropertyTableAfterAccessCheck
()
{
23343 v8::Isolate* isolate = CcTest::isolate();
23344 v8::HandleScope handle_scope(isolate);
23345 v8::Local<v8::ObjectTemplate> object_template =
23346 v8::ObjectTemplate::New(isolate);
23347 object_template->SetAccessCheckCallback(AccessCounter);
23348
23349 v8::Local<Context> context = Context::New(isolate);
23350 v8::Context::Scope context_scope(context);
23351
23352 v8::Local<v8::Object> obj =
23353 object_template->NewInstance(context).ToLocalChecked();
23354 obj->Set(context, v8_str("key"), v8_str("value")).FromJust();
23355 obj->Delete(context, v8_str("key")).FromJust();
23356
23357 obj->SetPrivate(context, v8::Private::New(isolate, v8_str("hidden key 2")),
23358 v8_str("hidden value 2"))
23359 .FromJust();
23360}
23361
23362
23363TEST(Regress411793)static void TestRegress411793(); CcTest register_test_Regress411793
(TestRegress411793, "../test/cctest/test-api.cc", "Regress411793"
, __null, true, true); static void TestRegress411793()
{
23364 v8::Isolate* isolate = CcTest::isolate();
23365 v8::HandleScope handle_scope(isolate);
23366 v8::Local<v8::ObjectTemplate> object_template =
23367 v8::ObjectTemplate::New(isolate);
23368 object_template->SetAccessCheckCallback(AccessCounter);
23369
23370 v8::Local<Context> context = Context::New(isolate);
23371 v8::Context::Scope context_scope(context);
23372
23373 CHECK(context->Global()do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("o"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23376, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"o\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
23374 ->Set(context, v8_str("o"),do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("o"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23376, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"o\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
23375 object_template->NewInstance(context).ToLocalChecked())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("o"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23376, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"o\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
23376 .FromJust())do { if ((__builtin_expect(!!(!(context->Global() ->Set
(context, v8_str("o"), object_template->NewInstance(context
).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 23376, "Check failed: %s.", "context->Global() ->Set(context, v8_str(\"o\"), object_template->NewInstance(context).ToLocalChecked()) .FromJust()"
); } } while (0)
;
23377 CompileRun(
23378 "Object.defineProperty(o, 'key', "
23379 " { get: function() {}, set: function() {} });");
23380}
23381
23382class TestSourceStream : public v8::ScriptCompiler::ExternalSourceStream {
23383 public:
23384 explicit TestSourceStream(const char** chunks) : chunks_(chunks), index_(0) {}
23385
23386 virtual size_t GetMoreData(const uint8_t** src) {
23387 // Unlike in real use cases, this function will never block.
23388 if (chunks_[index_] == NULL__null) {
23389 return 0;
23390 }
23391 // Copy the data, since the caller takes ownership of it.
23392 size_t len = strlen(chunks_[index_]);
23393 // We don't need to zero-terminate since we return the length.
23394 uint8_t* copy = new uint8_t[len];
23395 memcpy(copy, chunks_[index_], len);
23396 *src = copy;
23397 ++index_;
23398 return len;
23399 }
23400
23401 // Helper for constructing a string from chunks (the compilation needs it
23402 // too).
23403 static char* FullSourceString(const char** chunks) {
23404 size_t total_len = 0;
23405 for (size_t i = 0; chunks[i] != NULL__null; ++i) {
23406 total_len += strlen(chunks[i]);
23407 }
23408 char* full_string = new char[total_len + 1];
23409 size_t offset = 0;
23410 for (size_t i = 0; chunks[i] != NULL__null; ++i) {
23411 size_t len = strlen(chunks[i]);
23412 memcpy(full_string + offset, chunks[i], len);
23413 offset += len;
23414 }
23415 full_string[total_len] = 0;
23416 return full_string;
23417 }
23418
23419 private:
23420 const char** chunks_;
23421 unsigned index_;
23422};
23423
23424
23425// Helper function for running streaming tests.
23426void RunStreamingTest(const char** chunks,
23427 v8::ScriptCompiler::StreamedSource::Encoding encoding =
23428 v8::ScriptCompiler::StreamedSource::ONE_BYTE,
23429 bool expected_success = true,
23430 const char* expected_source_url = NULL__null,
23431 const char* expected_source_mapping_url = NULL__null) {
23432 LocalContext env;
23433 v8::Isolate* isolate = env->GetIsolate();
23434 v8::HandleScope scope(isolate);
23435 v8::TryCatch try_catch(isolate);
23436
23437 v8::ScriptCompiler::StreamedSource source(new TestSourceStream(chunks),
23438 encoding);
23439 v8::ScriptCompiler::ScriptStreamingTask* task =
23440 v8::ScriptCompiler::StartStreamingScript(isolate, &source);
23441
23442 // TestSourceStream::GetMoreData won't block, so it's OK to just run the
23443 // task here in the main thread.
23444 task->Run();
23445 delete task;
23446
23447 // Possible errors are only produced while compiling.
23448 CHECK_EQ(false, try_catch.HasCaught())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (try_catch.HasCaught()), "false" " " "==" " " "try_catch.HasCaught()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23448, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23449
23450 v8::ScriptOrigin origin(v8_str("http://foo.com"));
23451 char* full_source = TestSourceStream::FullSourceString(chunks);
23452 v8::MaybeLocal<Script> script = v8::ScriptCompiler::Compile(
23453 env.local(), &source, v8_str(full_source), origin);
23454 if (expected_success) {
23455 CHECK(!script.IsEmpty())do { if ((__builtin_expect(!!(!(!script.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 23455, "Check failed: %s.", "!script.IsEmpty()"
); } } while (0)
;
23456 v8::Local<Value> result(
23457 script.ToLocalChecked()->Run(env.local()).ToLocalChecked());
23458 // All scripts are supposed to return the fixed value 13 when ran.
23459 CHECK_EQ(13, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (13), (
result->Int32Value(env.local()).FromJust()), "13" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 23459, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
23460 CheckMagicComments(script.ToLocalChecked(), expected_source_url,
23461 expected_source_mapping_url);
23462 } else {
23463 CHECK(script.IsEmpty())do { if ((__builtin_expect(!!(!(script.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 23463, "Check failed: %s.", "script.IsEmpty()"
); } } while (0)
;
23464 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 23464, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
23465 }
23466 delete[] full_source;
23467}
23468
23469
23470TEST(StreamingSimpleScript)static void TestStreamingSimpleScript(); CcTest register_test_StreamingSimpleScript
(TestStreamingSimpleScript, "../test/cctest/test-api.cc", "StreamingSimpleScript"
, __null, true, true); static void TestStreamingSimpleScript(
)
{
23471 // This script is unrealistically small, since no one chunk is enough to fill
23472 // the backing buffer of Scanner, let alone overflow it.
23473 const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ",
23474 NULL__null};
23475 RunStreamingTest(chunks);
23476}
23477
23478
23479TEST(StreamingBiggerScript)static void TestStreamingBiggerScript(); CcTest register_test_StreamingBiggerScript
(TestStreamingBiggerScript, "../test/cctest/test-api.cc", "StreamingBiggerScript"
, __null, true, true); static void TestStreamingBiggerScript(
)
{
23480 const char* chunk1 =
23481 "function foo() {\n"
23482 " // Make this chunk sufficiently long so that it will overflow the\n"
23483 " // backing buffer of the Scanner.\n"
23484 " var i = 0;\n"
23485 " var result = 0;\n"
23486 " for (i = 0; i < 13; ++i) { result = result + 1; }\n"
23487 " result = 0;\n"
23488 " for (i = 0; i < 13; ++i) { result = result + 1; }\n"
23489 " result = 0;\n"
23490 " for (i = 0; i < 13; ++i) { result = result + 1; }\n"
23491 " result = 0;\n"
23492 " for (i = 0; i < 13; ++i) { result = result + 1; }\n"
23493 " return result;\n"
23494 "}\n";
23495 const char* chunks[] = {chunk1, "foo(); ", NULL__null};
23496 RunStreamingTest(chunks);
23497}
23498
23499
23500TEST(StreamingScriptWithParseError)static void TestStreamingScriptWithParseError(); CcTest register_test_StreamingScriptWithParseError
(TestStreamingScriptWithParseError, "../test/cctest/test-api.cc"
, "StreamingScriptWithParseError", __null, true, true); static
void TestStreamingScriptWithParseError()
{
23501 // Test that parse errors from streamed scripts are propagated correctly.
23502 {
23503 char chunk1[] =
23504 " // This will result in a parse error.\n"
23505 " var if else then foo";
23506 char chunk2[] = " 13\n";
23507 const char* chunks[] = {chunk1, chunk2, "foo();", NULL__null};
23508
23509 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::ONE_BYTE,
23510 false);
23511 }
23512 // Test that the next script succeeds normally.
23513 {
23514 char chunk1[] =
23515 " // This will be parsed successfully.\n"
23516 " function foo() { return ";
23517 char chunk2[] = " 13; }\n";
23518 const char* chunks[] = {chunk1, chunk2, "foo();", NULL__null};
23519
23520 RunStreamingTest(chunks);
23521 }
23522}
23523
23524
23525TEST(StreamingUtf8Script)static void TestStreamingUtf8Script(); CcTest register_test_StreamingUtf8Script
(TestStreamingUtf8Script, "../test/cctest/test-api.cc", "StreamingUtf8Script"
, __null, true, true); static void TestStreamingUtf8Script()
{
23526 // We'd want to write \uc481 instead of \xec\x92\x81, but Windows compilers
23527 // don't like it.
23528 const char* chunk1 =
23529 "function foo() {\n"
23530 " // This function will contain an UTF-8 character which is not in\n"
23531 " // ASCII.\n"
23532 " var foob\xec\x92\x81r = 13;\n"
23533 " return foob\xec\x92\x81r;\n"
23534 "}\n";
23535 const char* chunks[] = {chunk1, "foo(); ", NULL__null};
23536 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
23537}
23538
23539
23540TEST(StreamingUtf8ScriptWithSplitCharactersSanityCheck)static void TestStreamingUtf8ScriptWithSplitCharactersSanityCheck
(); CcTest register_test_StreamingUtf8ScriptWithSplitCharactersSanityCheck
(TestStreamingUtf8ScriptWithSplitCharactersSanityCheck, "../test/cctest/test-api.cc"
, "StreamingUtf8ScriptWithSplitCharactersSanityCheck", __null
, true, true); static void TestStreamingUtf8ScriptWithSplitCharactersSanityCheck
()
{
23541 // A sanity check to prove that the approach of splitting UTF-8
23542 // characters is correct. Here is an UTF-8 character which will take three
23543 // bytes.
23544 const char* reference = "\xec\x92\x81";
23545 CHECK(3u == strlen(reference))do { if ((__builtin_expect(!!(!(3u == strlen(reference))), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 23545, "Check failed: %s."
, "3u == strlen(reference)"); } } while (0)
; // NOLINT - no CHECK_EQ for unsigned.
23546
23547 char chunk1[] =
23548 "function foo() {\n"
23549 " // This function will contain an UTF-8 character which is not in\n"
23550 " // ASCII.\n"
23551 " var foob";
23552 char chunk2[] =
23553 "XXXr = 13;\n"
23554 " return foob\xec\x92\x81r;\n"
23555 "}\n";
23556 for (int i = 0; i < 3; ++i) {
23557 chunk2[i] = reference[i];
23558 }
23559 const char* chunks[] = {chunk1, chunk2, "foo();", NULL__null};
23560 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
23561}
23562
23563
23564TEST(StreamingUtf8ScriptWithSplitCharacters)static void TestStreamingUtf8ScriptWithSplitCharacters(); CcTest
register_test_StreamingUtf8ScriptWithSplitCharacters(TestStreamingUtf8ScriptWithSplitCharacters
, "../test/cctest/test-api.cc", "StreamingUtf8ScriptWithSplitCharacters"
, __null, true, true); static void TestStreamingUtf8ScriptWithSplitCharacters
()
{
23565 // Stream data where a multi-byte UTF-8 character is split between two data
23566 // chunks.
23567 const char* reference = "\xec\x92\x81";
23568 char chunk1[] =
23569 "function foo() {\n"
23570 " // This function will contain an UTF-8 character which is not in\n"
23571 " // ASCII.\n"
23572 " var foobX";
23573 char chunk2[] =
23574 "XXr = 13;\n"
23575 " return foob\xec\x92\x81r;\n"
23576 "}\n";
23577 chunk1[strlen(chunk1) - 1] = reference[0];
23578 chunk2[0] = reference[1];
23579 chunk2[1] = reference[2];
23580 const char* chunks[] = {chunk1, chunk2, "foo();", NULL__null};
23581 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
23582}
23583
23584
23585TEST(StreamingUtf8ScriptWithSplitCharactersValidEdgeCases)static void TestStreamingUtf8ScriptWithSplitCharactersValidEdgeCases
(); CcTest register_test_StreamingUtf8ScriptWithSplitCharactersValidEdgeCases
(TestStreamingUtf8ScriptWithSplitCharactersValidEdgeCases, "../test/cctest/test-api.cc"
, "StreamingUtf8ScriptWithSplitCharactersValidEdgeCases", __null
, true, true); static void TestStreamingUtf8ScriptWithSplitCharactersValidEdgeCases
()
{
23586 // Tests edge cases which should still be decoded correctly.
23587
23588 // Case 1: a chunk contains only bytes for a split character (and no other
23589 // data). This kind of a chunk would be exceptionally small, but we should
23590 // still decode it correctly.
23591 const char* reference = "\xec\x92\x81";
23592 // The small chunk is at the beginning of the split character
23593 {
23594 char chunk1[] =
23595 "function foo() {\n"
23596 " // This function will contain an UTF-8 character which is not in\n"
23597 " // ASCII.\n"
23598 " var foob";
23599 char chunk2[] = "XX";
23600 char chunk3[] =
23601 "Xr = 13;\n"
23602 " return foob\xec\x92\x81r;\n"
23603 "}\n";
23604 chunk2[0] = reference[0];
23605 chunk2[1] = reference[1];
23606 chunk3[0] = reference[2];
23607 const char* chunks[] = {chunk1, chunk2, chunk3, "foo();", NULL__null};
23608 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
23609 }
23610 // The small chunk is at the end of a character
23611 {
23612 char chunk1[] =
23613 "function foo() {\n"
23614 " // This function will contain an UTF-8 character which is not in\n"
23615 " // ASCII.\n"
23616 " var foobX";
23617 char chunk2[] = "XX";
23618 char chunk3[] =
23619 "r = 13;\n"
23620 " return foob\xec\x92\x81r;\n"
23621 "}\n";
23622 chunk1[strlen(chunk1) - 1] = reference[0];
23623 chunk2[0] = reference[1];
23624 chunk2[1] = reference[2];
23625 const char* chunks[] = {chunk1, chunk2, chunk3, "foo();", NULL__null};
23626 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
23627 }
23628 // Case 2: the script ends with a multi-byte character. Make sure that it's
23629 // decoded correctly and not just ignored.
23630 {
23631 char chunk1[] =
23632 "var foob\xec\x92\x81 = 13;\n"
23633 "foob\xec\x92\x81";
23634 const char* chunks[] = {chunk1, NULL__null};
23635 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
23636 }
23637}
23638
23639
23640TEST(StreamingUtf8ScriptWithSplitCharactersInvalidEdgeCases)static void TestStreamingUtf8ScriptWithSplitCharactersInvalidEdgeCases
(); CcTest register_test_StreamingUtf8ScriptWithSplitCharactersInvalidEdgeCases
(TestStreamingUtf8ScriptWithSplitCharactersInvalidEdgeCases, "../test/cctest/test-api.cc"
, "StreamingUtf8ScriptWithSplitCharactersInvalidEdgeCases", __null
, true, true); static void TestStreamingUtf8ScriptWithSplitCharactersInvalidEdgeCases
()
{
23641 // Test cases where a UTF-8 character is split over several chunks. Those
23642 // cases are not supported (the embedder should give the data in big enough
23643 // chunks), but we shouldn't crash, just produce a parse error.
23644 const char* reference = "\xec\x92\x81";
23645 char chunk1[] =
23646 "function foo() {\n"
23647 " // This function will contain an UTF-8 character which is not in\n"
23648 " // ASCII.\n"
23649 " var foobX";
23650 char chunk2[] = "X";
23651 char chunk3[] =
23652 "Xr = 13;\n"
23653 " return foob\xec\x92\x81r;\n"
23654 "}\n";
23655 chunk1[strlen(chunk1) - 1] = reference[0];
23656 chunk2[0] = reference[1];
23657 chunk3[0] = reference[2];
23658 const char* chunks[] = {chunk1, chunk2, chunk3, "foo();", NULL__null};
23659
23660 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, false);
23661}
23662
23663
23664TEST(StreamingProducesParserCache)static void TestStreamingProducesParserCache(); CcTest register_test_StreamingProducesParserCache
(TestStreamingProducesParserCache, "../test/cctest/test-api.cc"
, "StreamingProducesParserCache", __null, true, true); static
void TestStreamingProducesParserCache()
{
23665 i::FLAG_min_preparse_length = 0;
23666 const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ",
23667 NULL__null};
23668
23669 LocalContext env;
23670 v8::Isolate* isolate = env->GetIsolate();
23671 v8::HandleScope scope(isolate);
23672
23673 v8::ScriptCompiler::StreamedSource source(
23674 new TestSourceStream(chunks),
23675 v8::ScriptCompiler::StreamedSource::ONE_BYTE);
23676 v8::ScriptCompiler::ScriptStreamingTask* task =
23677 v8::ScriptCompiler::StartStreamingScript(
23678 isolate, &source, v8::ScriptCompiler::kProduceParserCache);
23679
23680 // TestSourceStream::GetMoreData won't block, so it's OK to just run the
23681 // task here in the main thread.
23682 task->Run();
23683 delete task;
23684
23685 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData();
23686 CHECK(cached_data != NULL)do { if ((__builtin_expect(!!(!(cached_data != __null)), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 23686, "Check failed: %s."
, "cached_data != NULL"); } } while (0)
;
23687 CHECK(cached_data->data != NULL)do { if ((__builtin_expect(!!(!(cached_data->data != __null
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 23687, "Check failed: %s."
, "cached_data->data != NULL"); } } while (0)
;
23688 CHECK(!cached_data->rejected)do { if ((__builtin_expect(!!(!(!cached_data->rejected)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 23688, "Check failed: %s."
, "!cached_data->rejected"); } } while (0)
;
23689 CHECK_GT(cached_data->length, 0)do { if (std::string* _msg = ::v8::base::CheckGTImpl( (cached_data
->length), (0), "cached_data->length" " " ">" " " "0"
)) { V8_Fatal("../test/cctest/test-api.cc", 23689, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23690}
23691
23692
23693TEST(StreamingWithDebuggingEnabledLate)static void TestStreamingWithDebuggingEnabledLate(); CcTest register_test_StreamingWithDebuggingEnabledLate
(TestStreamingWithDebuggingEnabledLate, "../test/cctest/test-api.cc"
, "StreamingWithDebuggingEnabledLate", __null, true, true); static
void TestStreamingWithDebuggingEnabledLate()
{
23694 // The streaming parser can only parse lazily, i.e. inner functions are not
23695 // fully parsed. However, we may compile inner functions eagerly when
23696 // debugging. Make sure that we can deal with this when turning on debugging
23697 // after streaming parser has already finished parsing.
23698 i::FLAG_min_preparse_length = 0;
23699 const char* chunks[] = {"with({x:1}) {",
23700 " var foo = function foo(y) {",
23701 " return x + y;",
23702 " };",
23703 " foo(2);",
23704 "}",
23705 NULL__null};
23706
23707 LocalContext env;
23708 v8::Isolate* isolate = env->GetIsolate();
23709 v8::HandleScope scope(isolate);
23710 v8::TryCatch try_catch(isolate);
23711
23712 v8::ScriptCompiler::StreamedSource source(
23713 new TestSourceStream(chunks),
23714 v8::ScriptCompiler::StreamedSource::ONE_BYTE);
23715 v8::ScriptCompiler::ScriptStreamingTask* task =
23716 v8::ScriptCompiler::StartStreamingScript(isolate, &source);
23717
23718 task->Run();
23719 delete task;
23720
23721 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 23721, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
23722
23723 v8::ScriptOrigin origin(v8_str("http://foo.com"));
23724 char* full_source = TestSourceStream::FullSourceString(chunks);
23725
23726 EnableDebugger(isolate);
23727
23728 v8::Local<Script> script =
23729 v8::ScriptCompiler::Compile(env.local(), &source, v8_str(full_source),
23730 origin)
23731 .ToLocalChecked();
23732
23733 Maybe<uint32_t> result =
23734 script->Run(env.local()).ToLocalChecked()->Uint32Value(env.local());
23735 CHECK_EQ(3U, result.FromMaybe(0))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3U), (
result.FromMaybe(0)), "3U" " " "==" " " "result.FromMaybe(0)"
)) { V8_Fatal("../test/cctest/test-api.cc", 23735, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23736
23737 delete[] full_source;
23738
23739 DisableDebugger(isolate);
23740}
23741
23742
23743TEST(StreamingScriptWithInvalidUtf8)static void TestStreamingScriptWithInvalidUtf8(); CcTest register_test_StreamingScriptWithInvalidUtf8
(TestStreamingScriptWithInvalidUtf8, "../test/cctest/test-api.cc"
, "StreamingScriptWithInvalidUtf8", __null, true, true); static
void TestStreamingScriptWithInvalidUtf8()
{
23744 // Regression test for a crash: test that invalid UTF-8 bytes in the end of a
23745 // chunk don't produce a crash.
23746 const char* reference = "\xec\x92\x81\x80\x80";
23747 char chunk1[] =
23748 "function foo() {\n"
23749 " // This function will contain an UTF-8 character which is not in\n"
23750 " // ASCII.\n"
23751 " var foobXXXXX"; // Too many bytes which look like incomplete chars!
23752 char chunk2[] =
23753 "r = 13;\n"
23754 " return foob\xec\x92\x81\x80\x80r;\n"
23755 "}\n";
23756 for (int i = 0; i < 5; ++i) chunk1[strlen(chunk1) - 5 + i] = reference[i];
23757
23758 const char* chunks[] = {chunk1, chunk2, "foo();", NULL__null};
23759 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, false);
23760}
23761
23762
23763TEST(StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit)static void TestStreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit
(); CcTest register_test_StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit
(TestStreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit
, "../test/cctest/test-api.cc", "StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit"
, __null, true, true); static void TestStreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit
()
{
23764 // Regression test: Stream data where there are several multi-byte UTF-8
23765 // characters in a sequence and one of them is split between two data chunks.
23766 const char* reference = "\xec\x92\x81";
23767 char chunk1[] =
23768 "function foo() {\n"
23769 " // This function will contain an UTF-8 character which is not in\n"
23770 " // ASCII.\n"
23771 " var foob\xec\x92\x81X";
23772 char chunk2[] =
23773 "XXr = 13;\n"
23774 " return foob\xec\x92\x81\xec\x92\x81r;\n"
23775 "}\n";
23776 chunk1[strlen(chunk1) - 1] = reference[0];
23777 chunk2[0] = reference[1];
23778 chunk2[1] = reference[2];
23779 const char* chunks[] = {chunk1, chunk2, "foo();", NULL__null};
23780 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
23781}
23782
23783
23784TEST(StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2)static void TestStreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2
(); CcTest register_test_StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2
(TestStreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2
, "../test/cctest/test-api.cc", "StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2"
, __null, true, true); static void TestStreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2
()
{
23785 // Another regression test, similar to the previous one. The difference is
23786 // that the split character is not the last one in the sequence.
23787 const char* reference = "\xec\x92\x81";
23788 char chunk1[] =
23789 "function foo() {\n"
23790 " // This function will contain an UTF-8 character which is not in\n"
23791 " // ASCII.\n"
23792 " var foobX";
23793 char chunk2[] =
23794 "XX\xec\x92\x81r = 13;\n"
23795 " return foob\xec\x92\x81\xec\x92\x81r;\n"
23796 "}\n";
23797 chunk1[strlen(chunk1) - 1] = reference[0];
23798 chunk2[0] = reference[1];
23799 chunk2[1] = reference[2];
23800 const char* chunks[] = {chunk1, chunk2, "foo();", NULL__null};
23801 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
23802}
23803
23804
23805TEST(StreamingWithHarmonyScopes)static void TestStreamingWithHarmonyScopes(); CcTest register_test_StreamingWithHarmonyScopes
(TestStreamingWithHarmonyScopes, "../test/cctest/test-api.cc"
, "StreamingWithHarmonyScopes", __null, true, true); static void
TestStreamingWithHarmonyScopes()
{
23806 // Don't use RunStreamingTest here so that both scripts get to use the same
23807 // LocalContext and HandleScope.
23808 LocalContext env;
23809 v8::Isolate* isolate = env->GetIsolate();
23810 v8::HandleScope scope(isolate);
23811
23812 // First, run a script with a let variable.
23813 CompileRun("\"use strict\"; let x = 1;");
23814
23815 // Then stream a script which (erroneously) tries to introduce the same
23816 // variable again.
23817 const char* chunks[] = {"\"use strict\"; let x = 2;", NULL__null};
23818
23819 v8::TryCatch try_catch(isolate);
23820 v8::ScriptCompiler::StreamedSource source(
23821 new TestSourceStream(chunks),
23822 v8::ScriptCompiler::StreamedSource::ONE_BYTE);
23823 v8::ScriptCompiler::ScriptStreamingTask* task =
23824 v8::ScriptCompiler::StartStreamingScript(isolate, &source);
23825 task->Run();
23826 delete task;
23827
23828 // Parsing should succeed (the script will be parsed and compiled in a context
23829 // independent way, so the error is not detected).
23830 CHECK_EQ(false, try_catch.HasCaught())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (try_catch.HasCaught()), "false" " " "==" " " "try_catch.HasCaught()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23830, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23831
23832 v8::ScriptOrigin origin(v8_str("http://foo.com"));
23833 char* full_source = TestSourceStream::FullSourceString(chunks);
23834 v8::Local<Script> script =
23835 v8::ScriptCompiler::Compile(env.local(), &source, v8_str(full_source),
23836 origin)
23837 .ToLocalChecked();
23838 CHECK(!script.IsEmpty())do { if ((__builtin_expect(!!(!(!script.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 23838, "Check failed: %s.", "!script.IsEmpty()"
); } } while (0)
;
23839 CHECK_EQ(false, try_catch.HasCaught())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (false)
, (try_catch.HasCaught()), "false" " " "==" " " "try_catch.HasCaught()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23839, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23840
23841 // Running the script exposes the error.
23842 CHECK(script->Run(env.local()).IsEmpty())do { if ((__builtin_expect(!!(!(script->Run(env.local()).IsEmpty
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 23842, "Check failed: %s."
, "script->Run(env.local()).IsEmpty()"); } } while (0)
;
23843 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 23843, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
23844 delete[] full_source;
23845}
23846
23847
23848TEST(CodeCache)static void TestCodeCache(); CcTest register_test_CodeCache(TestCodeCache
, "../test/cctest/test-api.cc", "CodeCache", __null, true, true
); static void TestCodeCache()
{
23849 v8::Isolate::CreateParams create_params;
23850 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
23851
23852 const char* source = "Math.sqrt(4)";
23853 const char* origin = "code cache test";
23854 v8::ScriptCompiler::CachedData* cache;
23855
23856 v8::Isolate* isolate1 = v8::Isolate::New(create_params);
23857 {
23858 v8::Isolate::Scope iscope(isolate1);
23859 v8::HandleScope scope(isolate1);
23860 v8::Local<v8::Context> context = v8::Context::New(isolate1);
23861 v8::Context::Scope cscope(context);
23862 v8::Local<v8::String> source_string = v8_str(source);
23863 v8::ScriptOrigin script_origin(v8_str(origin));
23864 v8::ScriptCompiler::Source source(source_string, script_origin);
23865 v8::ScriptCompiler::CompileOptions option =
23866 v8::ScriptCompiler::kProduceCodeCache;
23867 v8::ScriptCompiler::Compile(context, &source, option).ToLocalChecked();
23868 int length = source.GetCachedData()->length;
23869 uint8_t* cache_data = new uint8_t[length];
23870 memcpy(cache_data, source.GetCachedData()->data, length);
23871 cache = new v8::ScriptCompiler::CachedData(
23872 cache_data, length, v8::ScriptCompiler::CachedData::BufferOwned);
23873 }
23874 isolate1->Dispose();
23875
23876 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
23877 {
23878 v8::Isolate::Scope iscope(isolate2);
23879 v8::HandleScope scope(isolate2);
23880 v8::Local<v8::Context> context = v8::Context::New(isolate2);
23881 v8::Context::Scope cscope(context);
23882 v8::Local<v8::String> source_string = v8_str(source);
23883 v8::ScriptOrigin script_origin(v8_str(origin));
23884 v8::ScriptCompiler::Source source(source_string, script_origin, cache);
23885 v8::ScriptCompiler::CompileOptions option =
23886 v8::ScriptCompiler::kConsumeCodeCache;
23887 v8::Local<v8::Script> script;
23888 {
23889 i::DisallowCompilation no_compile(
23890 reinterpret_cast<i::Isolate*>(isolate2));
23891 script = v8::ScriptCompiler::Compile(context, &source, option)
23892 .ToLocalChecked();
23893 }
23894 CHECK_EQ(2, script->Run(context)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (script
->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "2" " " "==" " " "script->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23899, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23895 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (script
->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "2" " " "==" " " "script->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23899, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23896 ->ToInt32(context)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (script
->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "2" " " "==" " " "script->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23899, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23897 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (script
->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "2" " " "==" " " "script->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23899, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23898 ->Int32Value(context)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (script
->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "2" " " "==" " " "script->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23899, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23899 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (script
->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked
() ->Int32Value(context) .FromJust()), "2" " " "==" " " "script->Run(context) .ToLocalChecked() ->ToInt32(context) .ToLocalChecked() ->Int32Value(context) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23899, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23900 }
23901 isolate2->Dispose();
23902}
23903
23904
23905void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) {
23906 const char* garbage = "garbage garbage garbage garbage garbage garbage";
23907 const uint8_t* data = reinterpret_cast<const uint8_t*>(garbage);
23908 int length = 16;
23909 v8::ScriptCompiler::CachedData* cached_data =
23910 new v8::ScriptCompiler::CachedData(data, length);
23911 CHECK(!cached_data->rejected)do { if ((__builtin_expect(!!(!(!cached_data->rejected)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 23911, "Check failed: %s."
, "!cached_data->rejected"); } } while (0)
;
23912 v8::ScriptOrigin origin(v8_str("origin"));
23913 v8::ScriptCompiler::Source source(v8_str("42"), origin, cached_data);
23914 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext();
23915 v8::Local<v8::Script> script =
23916 v8::ScriptCompiler::Compile(context, &source, option).ToLocalChecked();
23917 CHECK(cached_data->rejected)do { if ((__builtin_expect(!!(!(cached_data->rejected)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 23917, "Check failed: %s."
, "cached_data->rejected"); } } while (0)
;
23918 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(context).ToLocalChecked()->Int32Value(context
).FromJust()), "42" " " "==" " " "script->Run(context).ToLocalChecked()->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23920, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23919 42,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(context).ToLocalChecked()->Int32Value(context
).FromJust()), "42" " " "==" " " "script->Run(context).ToLocalChecked()->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23920, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
23920 script->Run(context).ToLocalChecked()->Int32Value(context).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
script->Run(context).ToLocalChecked()->Int32Value(context
).FromJust()), "42" " " "==" " " "script->Run(context).ToLocalChecked()->Int32Value(context).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 23920, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23921}
23922
23923
23924TEST(InvalidCacheData)static void TestInvalidCacheData(); CcTest register_test_InvalidCacheData
(TestInvalidCacheData, "../test/cctest/test-api.cc", "InvalidCacheData"
, __null, true, true); static void TestInvalidCacheData()
{
23925 v8::V8::Initialize();
23926 v8::HandleScope scope(CcTest::isolate());
23927 LocalContext context;
23928 TestInvalidCacheData(v8::ScriptCompiler::kConsumeParserCache);
23929 TestInvalidCacheData(v8::ScriptCompiler::kConsumeCodeCache);
23930}
23931
23932
23933TEST(ParserCacheRejectedGracefully)static void TestParserCacheRejectedGracefully(); CcTest register_test_ParserCacheRejectedGracefully
(TestParserCacheRejectedGracefully, "../test/cctest/test-api.cc"
, "ParserCacheRejectedGracefully", __null, true, true); static
void TestParserCacheRejectedGracefully()
{
23934 i::FLAG_min_preparse_length = 0;
23935 v8::V8::Initialize();
23936 v8::HandleScope scope(CcTest::isolate());
23937 LocalContext context;
23938 // Produce valid cached data.
23939 v8::ScriptOrigin origin(v8_str("origin"));
23940 v8::Local<v8::String> source_str = v8_str("function foo() {}");
23941 v8::ScriptCompiler::Source source(source_str, origin);
23942 v8::Local<v8::Script> script =
23943 v8::ScriptCompiler::Compile(context.local(), &source,
23944 v8::ScriptCompiler::kProduceParserCache)
23945 .ToLocalChecked();
23946 USE(script);
23947 const v8::ScriptCompiler::CachedData* original_cached_data =
23948 source.GetCachedData();
23949 CHECK(original_cached_data != NULL)do { if ((__builtin_expect(!!(!(original_cached_data != __null
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 23949, "Check failed: %s."
, "original_cached_data != NULL"); } } while (0)
;
23950 CHECK(original_cached_data->data != NULL)do { if ((__builtin_expect(!!(!(original_cached_data->data
!= __null)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 23950
, "Check failed: %s.", "original_cached_data->data != NULL"
); } } while (0)
;
23951 CHECK(!original_cached_data->rejected)do { if ((__builtin_expect(!!(!(!original_cached_data->rejected
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 23951, "Check failed: %s."
, "!original_cached_data->rejected"); } } while (0)
;
23952 CHECK_GT(original_cached_data->length, 0)do { if (std::string* _msg = ::v8::base::CheckGTImpl( (original_cached_data
->length), (0), "original_cached_data->length" " " ">"
" " "0")) { V8_Fatal("../test/cctest/test-api.cc", 23952, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
23953 // Recompiling the same script with it won't reject the data.
23954 {
23955 v8::ScriptCompiler::Source source_with_cached_data(
23956 source_str, origin,
23957 new v8::ScriptCompiler::CachedData(original_cached_data->data,
23958 original_cached_data->length));
23959 v8::Local<v8::Script> script =
23960 v8::ScriptCompiler::Compile(context.local(), &source_with_cached_data,
23961 v8::ScriptCompiler::kConsumeParserCache)
23962 .ToLocalChecked();
23963 USE(script);
23964 const v8::ScriptCompiler::CachedData* new_cached_data =
23965 source_with_cached_data.GetCachedData();
23966 CHECK(new_cached_data != NULL)do { if ((__builtin_expect(!!(!(new_cached_data != __null)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 23966, "Check failed: %s."
, "new_cached_data != NULL"); } } while (0)
;
23967 CHECK(!new_cached_data->rejected)do { if ((__builtin_expect(!!(!(!new_cached_data->rejected
)), 0))) { V8_Fatal("../test/cctest/test-api.cc", 23967, "Check failed: %s."
, "!new_cached_data->rejected"); } } while (0)
;
23968 }
23969 // Compile an incompatible script with the cached data. The new script doesn't
23970 // have the same starting position for the function as the old one, so the old
23971 // cached data will be incompatible with it and will be rejected.
23972 {
23973 v8::Local<v8::String> incompatible_source_str =
23974 v8_str(" function foo() {}");
23975 v8::ScriptCompiler::Source source_with_cached_data(
23976 incompatible_source_str, origin,
23977 new v8::ScriptCompiler::CachedData(original_cached_data->data,
23978 original_cached_data->length));
23979 v8::Local<v8::Script> script =
23980 v8::ScriptCompiler::Compile(context.local(), &source_with_cached_data,
23981 v8::ScriptCompiler::kConsumeParserCache)
23982 .ToLocalChecked();
23983 USE(script);
23984 const v8::ScriptCompiler::CachedData* new_cached_data =
23985 source_with_cached_data.GetCachedData();
23986 CHECK(new_cached_data != NULL)do { if ((__builtin_expect(!!(!(new_cached_data != __null)), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 23986, "Check failed: %s."
, "new_cached_data != NULL"); } } while (0)
;
23987 CHECK(new_cached_data->rejected)do { if ((__builtin_expect(!!(!(new_cached_data->rejected)
), 0))) { V8_Fatal("../test/cctest/test-api.cc", 23987, "Check failed: %s."
, "new_cached_data->rejected"); } } while (0)
;
23988 }
23989}
23990
23991
23992TEST(StringConcatOverflow)static void TestStringConcatOverflow(); CcTest register_test_StringConcatOverflow
(TestStringConcatOverflow, "../test/cctest/test-api.cc", "StringConcatOverflow"
, __null, true, true); static void TestStringConcatOverflow()
{
23993 v8::V8::Initialize();
23994 v8::HandleScope scope(CcTest::isolate());
23995 RandomLengthOneByteResource* r =
23996 new RandomLengthOneByteResource(i::String::kMaxLength);
23997 v8::Local<v8::String> str =
23998 v8::String::NewExternalOneByte(CcTest::isolate(), r).ToLocalChecked();
23999 CHECK(!str.IsEmpty())do { if ((__builtin_expect(!!(!(!str.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 23999, "Check failed: %s.", "!str.IsEmpty()"
); } } while (0)
;
24000 v8::TryCatch try_catch(CcTest::isolate());
24001 v8::Local<v8::String> result = v8::String::Concat(str, str);
24002 CHECK(result.IsEmpty())do { if ((__builtin_expect(!!(!(result.IsEmpty())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24002, "Check failed: %s.", "result.IsEmpty()"
); } } while (0)
;
24003 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24003, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24004}
24005
24006
24007TEST(TurboAsmDisablesNeuter)static void TestTurboAsmDisablesNeuter(); CcTest register_test_TurboAsmDisablesNeuter
(TestTurboAsmDisablesNeuter, "../test/cctest/test-api.cc", "TurboAsmDisablesNeuter"
, __null, true, true); static void TestTurboAsmDisablesNeuter
()
{
24008 v8::V8::Initialize();
24009 v8::HandleScope scope(CcTest::isolate());
24010 LocalContext context;
24011 bool should_be_neuterable = !i::FLAG_turbo_asm;
24012 const char* load =
24013 "function Module(stdlib, foreign, heap) {"
24014 " 'use asm';"
24015 " var MEM32 = new stdlib.Int32Array(heap);"
24016 " function load() { return MEM32[0]; }"
24017 " return { load: load };"
24018 "}"
24019 "var buffer = new ArrayBuffer(4);"
24020 "Module(this, {}, buffer).load();"
24021 "buffer";
24022
24023 i::FLAG_turbo_osr = false; // TODO(titzer): test requires eager TF.
24024 v8::Local<v8::ArrayBuffer> result = CompileRun(load).As<v8::ArrayBuffer>();
24025 CHECK_EQ(should_be_neuterable, result->IsNeuterable())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (should_be_neuterable
), (result->IsNeuterable()), "should_be_neuterable" " " "=="
" " "result->IsNeuterable()")) { V8_Fatal("../test/cctest/test-api.cc"
, 24025, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
24026
24027 const char* store =
24028 "function Module(stdlib, foreign, heap) {"
24029 " 'use asm';"
24030 " var MEM32 = new stdlib.Int32Array(heap);"
24031 " function store() { MEM32[0] = 0; }"
24032 " return { store: store };"
24033 "}"
24034 "var buffer = new ArrayBuffer(4);"
24035 "Module(this, {}, buffer).store();"
24036 "buffer";
24037
24038 i::FLAG_turbo_osr = false; // TODO(titzer): test requires eager TF.
24039 result = CompileRun(store).As<v8::ArrayBuffer>();
24040 CHECK_EQ(should_be_neuterable, result->IsNeuterable())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (should_be_neuterable
), (result->IsNeuterable()), "should_be_neuterable" " " "=="
" " "result->IsNeuterable()")) { V8_Fatal("../test/cctest/test-api.cc"
, 24040, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
24041}
24042
24043
24044TEST(GetPrototypeAccessControl)static void TestGetPrototypeAccessControl(); CcTest register_test_GetPrototypeAccessControl
(TestGetPrototypeAccessControl, "../test/cctest/test-api.cc",
"GetPrototypeAccessControl", __null, true, true); static void
TestGetPrototypeAccessControl()
{
24045 i::FLAG_allow_natives_syntax = true;
24046 v8::Isolate* isolate = CcTest::isolate();
24047 v8::HandleScope handle_scope(isolate);
24048 LocalContext env;
24049
24050 v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
24051 obj_template->SetAccessCheckCallback(AccessAlwaysBlocked);
24052
24053 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("prohibited"), obj_template->NewInstance(
env.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24056, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"prohibited\"), obj_template->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
24054 ->Set(env.local(), v8_str("prohibited"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("prohibited"), obj_template->NewInstance(
env.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24056, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"prohibited\"), obj_template->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
24055 obj_template->NewInstance(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("prohibited"), obj_template->NewInstance(
env.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24056, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"prohibited\"), obj_template->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
24056 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("prohibited"), obj_template->NewInstance(
env.local()).ToLocalChecked()) .FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24056, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"prohibited\"), obj_template->NewInstance(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
24057
24058 CHECK(CompileRun(do { if ((__builtin_expect(!!(!(CompileRun( "function f() { return %_GetPrototype(prohibited); }"
"%OptimizeFunctionOnNextCall(f);" "f();")->IsNull())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 24061, "Check failed: %s."
, "CompileRun( \"function f() { return %_GetPrototype(prohibited); }\" \"%OptimizeFunctionOnNextCall(f);\" \"f();\")->IsNull()"
); } } while (0)
24059 "function f() { return %_GetPrototype(prohibited); }"do { if ((__builtin_expect(!!(!(CompileRun( "function f() { return %_GetPrototype(prohibited); }"
"%OptimizeFunctionOnNextCall(f);" "f();")->IsNull())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 24061, "Check failed: %s."
, "CompileRun( \"function f() { return %_GetPrototype(prohibited); }\" \"%OptimizeFunctionOnNextCall(f);\" \"f();\")->IsNull()"
); } } while (0)
24060 "%OptimizeFunctionOnNextCall(f);"do { if ((__builtin_expect(!!(!(CompileRun( "function f() { return %_GetPrototype(prohibited); }"
"%OptimizeFunctionOnNextCall(f);" "f();")->IsNull())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 24061, "Check failed: %s."
, "CompileRun( \"function f() { return %_GetPrototype(prohibited); }\" \"%OptimizeFunctionOnNextCall(f);\" \"f();\")->IsNull()"
); } } while (0)
24061 "f();")->IsNull())do { if ((__builtin_expect(!!(!(CompileRun( "function f() { return %_GetPrototype(prohibited); }"
"%OptimizeFunctionOnNextCall(f);" "f();")->IsNull())), 0)
)) { V8_Fatal("../test/cctest/test-api.cc", 24061, "Check failed: %s."
, "CompileRun( \"function f() { return %_GetPrototype(prohibited); }\" \"%OptimizeFunctionOnNextCall(f);\" \"f();\")->IsNull()"
); } } while (0)
;
24062}
24063
24064
24065TEST(GetPrototypeHidden)static void TestGetPrototypeHidden(); CcTest register_test_GetPrototypeHidden
(TestGetPrototypeHidden, "../test/cctest/test-api.cc", "GetPrototypeHidden"
, __null, true, true); static void TestGetPrototypeHidden()
{
24066 i::FLAG_allow_natives_syntax = true;
24067 v8::Isolate* isolate = CcTest::isolate();
24068 v8::HandleScope handle_scope(isolate);
24069 LocalContext env;
24070
24071 Local<FunctionTemplate> t = FunctionTemplate::New(isolate);
24072 t->SetHiddenPrototype(true);
24073 Local<Object> proto = t->GetFunction(env.local())
24074 .ToLocalChecked()
24075 ->NewInstance(env.local())
24076 .ToLocalChecked();
24077 Local<Object> object = Object::New(isolate);
24078 Local<Object> proto2 = Object::New(isolate);
24079 object->SetPrototype(env.local(), proto).FromJust();
24080 proto->SetPrototype(env.local(), proto2).FromJust();
24081
24082 CHECK(env->Global()->Set(env.local(), v8_str("object"), object).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("object"), object).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24082, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"object\"), object).FromJust()"
); } } while (0)
;
24083 CHECK(env->Global()->Set(env.local(), v8_str("proto"), proto).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("proto"), proto).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24083, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"proto\"), proto).FromJust()"
); } } while (0)
;
24084 CHECK(env->Global()->Set(env.local(), v8_str("proto2"), proto2).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("proto2"), proto2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24084, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"proto2\"), proto2).FromJust()"
); } } while (0)
;
24085
24086 v8::Local<v8::Value> result = CompileRun("%_GetPrototype(object)");
24087 CHECK(result->Equals(env.local(), proto2).FromJust())do { if ((__builtin_expect(!!(!(result->Equals(env.local()
, proto2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24087, "Check failed: %s.", "result->Equals(env.local(), proto2).FromJust()"
); } } while (0)
;
24088
24089 result = CompileRun(
24090 "function f() { return %_GetPrototype(object); }"
24091 "%OptimizeFunctionOnNextCall(f);"
24092 "f()");
24093 CHECK(result->Equals(env.local(), proto2).FromJust())do { if ((__builtin_expect(!!(!(result->Equals(env.local()
, proto2).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24093, "Check failed: %s.", "result->Equals(env.local(), proto2).FromJust()"
); } } while (0)
;
24094}
24095
24096
24097TEST(ClassPrototypeCreationContext)static void TestClassPrototypeCreationContext(); CcTest register_test_ClassPrototypeCreationContext
(TestClassPrototypeCreationContext, "../test/cctest/test-api.cc"
, "ClassPrototypeCreationContext", __null, true, true); static
void TestClassPrototypeCreationContext()
{
24098 v8::Isolate* isolate = CcTest::isolate();
24099 v8::HandleScope handle_scope(isolate);
24100 LocalContext env;
24101
24102 Local<Object> result = Local<Object>::Cast(
24103 CompileRun("'use strict'; class Example { }; Example.prototype"));
24104 CHECK(env.local() == result->CreationContext())do { if ((__builtin_expect(!!(!(env.local() == result->CreationContext
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24104, "Check failed: %s."
, "env.local() == result->CreationContext()"); } } while (
0)
;
24105}
24106
24107
24108TEST(SimpleStreamingScriptWithSourceURL)static void TestSimpleStreamingScriptWithSourceURL(); CcTest register_test_SimpleStreamingScriptWithSourceURL
(TestSimpleStreamingScriptWithSourceURL, "../test/cctest/test-api.cc"
, "SimpleStreamingScriptWithSourceURL", __null, true, true); static
void TestSimpleStreamingScriptWithSourceURL()
{
24109 const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo();\n",
24110 "//# sourceURL=bar2.js\n", NULL__null};
24111 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true,
24112 "bar2.js");
24113}
24114
24115
24116TEST(StreamingScriptWithSplitSourceURL)static void TestStreamingScriptWithSplitSourceURL(); CcTest register_test_StreamingScriptWithSplitSourceURL
(TestStreamingScriptWithSplitSourceURL, "../test/cctest/test-api.cc"
, "StreamingScriptWithSplitSourceURL", __null, true, true); static
void TestStreamingScriptWithSplitSourceURL()
{
24117 const char* chunks[] = {"function foo() { ret", "urn 13; } f",
24118 "oo();\n//# sourceURL=b", "ar2.js\n", NULL__null};
24119 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true,
24120 "bar2.js");
24121}
24122
24123
24124TEST(StreamingScriptWithSourceMappingURLInTheMiddle)static void TestStreamingScriptWithSourceMappingURLInTheMiddle
(); CcTest register_test_StreamingScriptWithSourceMappingURLInTheMiddle
(TestStreamingScriptWithSourceMappingURLInTheMiddle, "../test/cctest/test-api.cc"
, "StreamingScriptWithSourceMappingURLInTheMiddle", __null, true
, true); static void TestStreamingScriptWithSourceMappingURLInTheMiddle
()
{
24125 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#",
24126 " sourceMappingURL=bar2.js\n", "foo();", NULL__null};
24127 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL__null,
24128 "bar2.js");
24129}
24130
24131
24132TEST(NewStringRangeError)static void TestNewStringRangeError(); CcTest register_test_NewStringRangeError
(TestNewStringRangeError, "../test/cctest/test-api.cc", "NewStringRangeError"
, __null, true, true); static void TestNewStringRangeError()
{
24133 v8::Isolate* isolate = CcTest::isolate();
24134 v8::HandleScope handle_scope(isolate);
24135 const int length = i::String::kMaxLength + 1;
24136 const int buffer_size = length * sizeof(uint16_t);
24137 void* buffer = malloc(buffer_size);
24138 if (buffer == NULL__null) return;
24139 memset(buffer, 'A', buffer_size);
24140 {
24141 v8::TryCatch try_catch(isolate);
24142 char* data = reinterpret_cast<char*>(buffer);
24143 CHECK(v8::String::NewFromUtf8(isolate, data, v8::NewStringType::kNormal,do { if ((__builtin_expect(!!(!(v8::String::NewFromUtf8(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24145, "Check failed: %s."
, "v8::String::NewFromUtf8(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
24144 length)do { if ((__builtin_expect(!!(!(v8::String::NewFromUtf8(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24145, "Check failed: %s."
, "v8::String::NewFromUtf8(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
24145 .IsEmpty())do { if ((__builtin_expect(!!(!(v8::String::NewFromUtf8(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24145, "Check failed: %s."
, "v8::String::NewFromUtf8(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
;
24146 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24146, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24147 }
24148 {
24149 v8::TryCatch try_catch(isolate);
24150 uint8_t* data = reinterpret_cast<uint8_t*>(buffer);
24151 CHECK(v8::String::NewFromOneByte(isolate, data, v8::NewStringType::kNormal,do { if ((__builtin_expect(!!(!(v8::String::NewFromOneByte(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24153, "Check failed: %s."
, "v8::String::NewFromOneByte(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
24152 length)do { if ((__builtin_expect(!!(!(v8::String::NewFromOneByte(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24153, "Check failed: %s."
, "v8::String::NewFromOneByte(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
24153 .IsEmpty())do { if ((__builtin_expect(!!(!(v8::String::NewFromOneByte(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24153, "Check failed: %s."
, "v8::String::NewFromOneByte(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
;
24154 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24154, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24155 }
24156 {
24157 v8::TryCatch try_catch(isolate);
24158 uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
24159 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::NewStringType::kNormal,do { if ((__builtin_expect(!!(!(v8::String::NewFromTwoByte(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24161, "Check failed: %s."
, "v8::String::NewFromTwoByte(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
24160 length)do { if ((__builtin_expect(!!(!(v8::String::NewFromTwoByte(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24161, "Check failed: %s."
, "v8::String::NewFromTwoByte(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
24161 .IsEmpty())do { if ((__builtin_expect(!!(!(v8::String::NewFromTwoByte(isolate
, data, v8::NewStringType::kNormal, length) .IsEmpty())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24161, "Check failed: %s."
, "v8::String::NewFromTwoByte(isolate, data, v8::NewStringType::kNormal, length) .IsEmpty()"
); } } while (0)
;
24162 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24162, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24163 }
24164 free(buffer);
24165}
24166
24167
24168TEST(SealHandleScope)static void TestSealHandleScope(); CcTest register_test_SealHandleScope
(TestSealHandleScope, "../test/cctest/test-api.cc", "SealHandleScope"
, __null, true, true); static void TestSealHandleScope()
{
24169 v8::Isolate* isolate = CcTest::isolate();
24170 v8::HandleScope handle_scope(isolate);
24171 LocalContext env;
24172
24173 v8::SealHandleScope seal(isolate);
24174
24175 // Should fail
24176 v8::Local<v8::Object> obj = v8::Object::New(isolate);
24177
24178 USE(obj);
24179}
24180
24181
24182TEST(SealHandleScopeNested)static void TestSealHandleScopeNested(); CcTest register_test_SealHandleScopeNested
(TestSealHandleScopeNested, "../test/cctest/test-api.cc", "SealHandleScopeNested"
, __null, true, true); static void TestSealHandleScopeNested(
)
{
24183 v8::Isolate* isolate = CcTest::isolate();
24184 v8::HandleScope handle_scope(isolate);
24185 LocalContext env;
24186
24187 v8::SealHandleScope seal(isolate);
24188
24189 {
24190 v8::HandleScope handle_scope(isolate);
24191
24192 // Should work
24193 v8::Local<v8::Object> obj = v8::Object::New(isolate);
24194
24195 USE(obj);
24196 }
24197}
24198
24199
24200static bool access_was_called = false;
24201
24202static bool AccessAlwaysAllowedWithFlag(Local<v8::Context> accessing_context,
24203 Local<v8::Object> accessed_object,
24204 Local<v8::Value> data) {
24205 access_was_called = true;
24206 return true;
24207}
24208
24209static bool AccessAlwaysBlockedWithFlag(Local<v8::Context> accessing_context,
24210 Local<v8::Object> accessed_object,
24211 Local<v8::Value> data) {
24212 access_was_called = true;
24213 return false;
24214}
24215
24216
24217TEST(StrongModeAccessCheckAllowed)static void TestStrongModeAccessCheckAllowed(); CcTest register_test_StrongModeAccessCheckAllowed
(TestStrongModeAccessCheckAllowed, "../test/cctest/test-api.cc"
, "StrongModeAccessCheckAllowed", __null, true, true); static
void TestStrongModeAccessCheckAllowed()
{
24218 i::FLAG_strong_mode = true;
24219 v8::Isolate* isolate = CcTest::isolate();
24220 v8::HandleScope handle_scope(isolate);
24221 v8::Local<Value> value;
24222 access_was_called = false;
24223
24224 v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
24225
24226 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42));
24227 obj_template->SetAccessCheckCallback(AccessAlwaysAllowedWithFlag);
24228
24229 // Create an environment
24230 v8::Local<Context> context0 = Context::New(isolate, NULL__null, obj_template);
24231 context0->Enter();
24232 v8::Local<v8::Object> global0 = context0->Global();
24233 global0->Set(context0, v8_str("object"),
24234 obj_template->NewInstance(context0).ToLocalChecked())
24235 .FromJust();
24236 {
24237 v8::TryCatch try_catch(isolate);
24238 value = CompileRun("'use strong'; object.x");
24239 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24239, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24240 CHECK(!access_was_called)do { if ((__builtin_expect(!!(!(!access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24240, "Check failed: %s.", "!access_was_called"
); } } while (0)
;
24241 CHECK_EQ(42, value->Int32Value(context0).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context0).FromJust()), "42" " " "==" " "
"value->Int32Value(context0).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 24241, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
24242 }
24243 {
24244 v8::TryCatch try_catch(isolate);
24245 value = CompileRun("'use strong'; object.foo");
24246 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24246, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24247 CHECK(!access_was_called)do { if ((__builtin_expect(!!(!(!access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24247, "Check failed: %s.", "!access_was_called"
); } } while (0)
;
24248 }
24249 {
24250 v8::TryCatch try_catch(isolate);
24251 value = CompileRun("'use strong'; object[10]");
24252 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24252, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24253 CHECK(!access_was_called)do { if ((__builtin_expect(!!(!(!access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24253, "Check failed: %s.", "!access_was_called"
); } } while (0)
;
24254 }
24255
24256 // Create an environment
24257 v8::Local<Context> context1 = Context::New(isolate);
24258 context1->Enter();
24259 v8::Local<v8::Object> global1 = context1->Global();
24260 global1->Set(context1, v8_str("object"),
24261 obj_template->NewInstance(context1).ToLocalChecked())
24262 .FromJust();
24263 {
24264 v8::TryCatch try_catch(isolate);
24265 value = CompileRun("'use strong'; object.x");
24266 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24266, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24267 CHECK(access_was_called)do { if ((__builtin_expect(!!(!(access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24267, "Check failed: %s.", "access_was_called"
); } } while (0)
;
24268 CHECK_EQ(42, value->Int32Value(context1).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context1).FromJust()), "42" " " "==" " "
"value->Int32Value(context1).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 24268, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
24269 }
24270 access_was_called = false;
24271 {
24272 v8::TryCatch try_catch(isolate);
24273 value = CompileRun("'use strong'; object.foo");
24274 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24274, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24275 CHECK(access_was_called)do { if ((__builtin_expect(!!(!(access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24275, "Check failed: %s.", "access_was_called"
); } } while (0)
;
24276 }
24277 access_was_called = false;
24278 {
24279 v8::TryCatch try_catch(isolate);
24280 value = CompileRun("'use strong'; object[10]");
24281 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24281, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24282 CHECK(access_was_called)do { if ((__builtin_expect(!!(!(access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24282, "Check failed: %s.", "access_was_called"
); } } while (0)
;
24283 }
24284
24285 context1->Exit();
24286 context0->Exit();
24287}
24288
24289
24290TEST(StrongModeAccessCheckBlocked)static void TestStrongModeAccessCheckBlocked(); CcTest register_test_StrongModeAccessCheckBlocked
(TestStrongModeAccessCheckBlocked, "../test/cctest/test-api.cc"
, "StrongModeAccessCheckBlocked", __null, true, true); static
void TestStrongModeAccessCheckBlocked()
{
24291 i::FLAG_strong_mode = true;
24292 v8::Isolate* isolate = CcTest::isolate();
24293 v8::HandleScope handle_scope(isolate);
24294 v8::Local<Value> value;
24295 access_was_called = false;
24296
24297 v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
24298
24299 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42));
24300 obj_template->SetAccessCheckCallback(AccessAlwaysBlockedWithFlag);
24301
24302 // Create an environment
24303 v8::Local<Context> context0 = Context::New(isolate, NULL__null, obj_template);
24304 context0->Enter();
24305 v8::Local<v8::Object> global0 = context0->Global();
24306 global0->Set(context0, v8_str("object"),
24307 obj_template->NewInstance(context0).ToLocalChecked())
24308 .FromJust();
24309 {
24310 v8::TryCatch try_catch(isolate);
24311 value = CompileRun("'use strong'; object.x");
24312 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24312, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24313 CHECK(!access_was_called)do { if ((__builtin_expect(!!(!(!access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24313, "Check failed: %s.", "!access_was_called"
); } } while (0)
;
24314 CHECK_EQ(42, value->Int32Value(context0).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (42), (
value->Int32Value(context0).FromJust()), "42" " " "==" " "
"value->Int32Value(context0).FromJust()")) { V8_Fatal("../test/cctest/test-api.cc"
, 24314, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
24315 }
24316 {
24317 v8::TryCatch try_catch(isolate);
24318 value = CompileRun("'use strong'; object.foo");
24319 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24319, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24320 CHECK(!access_was_called)do { if ((__builtin_expect(!!(!(!access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24320, "Check failed: %s.", "!access_was_called"
); } } while (0)
;
24321 }
24322 {
24323 v8::TryCatch try_catch(isolate);
24324 value = CompileRun("'use strong'; object[10]");
24325 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24325, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24326 CHECK(!access_was_called)do { if ((__builtin_expect(!!(!(!access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24326, "Check failed: %s.", "!access_was_called"
); } } while (0)
;
24327 }
24328
24329 // Create an environment
24330 v8::Local<Context> context1 = Context::New(isolate);
24331 context1->Enter();
24332 v8::Local<v8::Object> global1 = context1->Global();
24333 global1->Set(context1, v8_str("object"),
24334 obj_template->NewInstance(context1).ToLocalChecked())
24335 .FromJust();
24336 {
24337 v8::TryCatch try_catch(isolate);
24338 value = CompileRun("'use strong'; object.x");
24339 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24339, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24340 CHECK(access_was_called)do { if ((__builtin_expect(!!(!(access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24340, "Check failed: %s.", "access_was_called"
); } } while (0)
;
24341 }
24342 access_was_called = false;
24343 {
24344 v8::TryCatch try_catch(isolate);
24345 value = CompileRun("'use strong'; object.foo");
24346 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24346, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24347 CHECK(access_was_called)do { if ((__builtin_expect(!!(!(access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24347, "Check failed: %s.", "access_was_called"
); } } while (0)
;
24348 }
24349 access_was_called = false;
24350 {
24351 v8::TryCatch try_catch(isolate);
24352 value = CompileRun("'use strong'; object[10]");
24353 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24353, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24354 CHECK(access_was_called)do { if ((__builtin_expect(!!(!(access_was_called)), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24354, "Check failed: %s.", "access_was_called"
); } } while (0)
;
24355 }
24356
24357 context1->Exit();
24358 context0->Exit();
24359}
24360
24361
24362TEST(StrongModeArityCallFromApi)static void TestStrongModeArityCallFromApi(); CcTest register_test_StrongModeArityCallFromApi
(TestStrongModeArityCallFromApi, "../test/cctest/test-api.cc"
, "StrongModeArityCallFromApi", __null, true, true); static void
TestStrongModeArityCallFromApi()
{
24363 i::FLAG_strong_mode = true;
24364 LocalContext env;
24365 v8::Isolate* isolate = env->GetIsolate();
24366 v8::HandleScope scope(isolate);
24367 Local<Function> fun;
24368 {
24369 v8::TryCatch try_catch(isolate);
24370 fun = Local<Function>::Cast(CompileRun(
24371 "function f(x) { 'use strong'; }"
24372 "f"));
24373
24374 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24374, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24375 }
24376
24377 {
24378 v8::TryCatch try_catch(isolate);
24379 CHECK(fun->Call(env.local(), v8::Undefined(isolate), 0, nullptr).IsEmpty())do { if ((__builtin_expect(!!(!(fun->Call(env.local(), v8::
Undefined(isolate), 0, nullptr).IsEmpty())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 24379, "Check failed: %s.", "fun->Call(env.local(), v8::Undefined(isolate), 0, nullptr).IsEmpty()"
); } } while (0)
;
24380 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24380, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24381 }
24382
24383 {
24384 v8::TryCatch try_catch(isolate);
24385 v8::Local<Value> args[] = {v8_num(42)};
24386 fun->Call(env.local(), v8::Undefined(isolate), arraysize(args)(sizeof(ArraySizeHelper(args))), args)
24387 .ToLocalChecked();
24388 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24388, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24389 }
24390
24391 {
24392 v8::TryCatch try_catch(isolate);
24393 v8::Local<Value> args[] = {v8_num(42), v8_num(555)};
24394 fun->Call(env.local(), v8::Undefined(isolate), arraysize(args)(sizeof(ArraySizeHelper(args))), args)
24395 .ToLocalChecked();
24396 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24396, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24397 }
24398}
24399
24400
24401TEST(StrongModeArityCallFromApi2)static void TestStrongModeArityCallFromApi2(); CcTest register_test_StrongModeArityCallFromApi2
(TestStrongModeArityCallFromApi2, "../test/cctest/test-api.cc"
, "StrongModeArityCallFromApi2", __null, true, true); static void
TestStrongModeArityCallFromApi2()
{
24402 i::FLAG_strong_mode = true;
24403 LocalContext env;
24404 v8::Isolate* isolate = env->GetIsolate();
24405 v8::HandleScope scope(isolate);
24406 Local<Function> fun;
24407 {
24408 v8::TryCatch try_catch(isolate);
24409 fun = Local<Function>::Cast(CompileRun(
24410 "'use strong';"
24411 "function f(x) {}"
24412 "f"));
24413
24414 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24414, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24415 }
24416
24417 {
24418 v8::TryCatch try_catch(isolate);
24419 CHECK(fun->Call(env.local(), v8::Undefined(isolate), 0, nullptr).IsEmpty())do { if ((__builtin_expect(!!(!(fun->Call(env.local(), v8::
Undefined(isolate), 0, nullptr).IsEmpty())), 0))) { V8_Fatal(
"../test/cctest/test-api.cc", 24419, "Check failed: %s.", "fun->Call(env.local(), v8::Undefined(isolate), 0, nullptr).IsEmpty()"
); } } while (0)
;
24420 CHECK(try_catch.HasCaught())do { if ((__builtin_expect(!!(!(try_catch.HasCaught())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24420, "Check failed: %s."
, "try_catch.HasCaught()"); } } while (0)
;
24421 }
24422
24423 {
24424 v8::TryCatch try_catch(isolate);
24425 v8::Local<Value> args[] = {v8_num(42)};
24426 fun->Call(env.local(), v8::Undefined(isolate), arraysize(args)(sizeof(ArraySizeHelper(args))), args)
24427 .ToLocalChecked();
24428 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24428, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24429 }
24430
24431 {
24432 v8::TryCatch try_catch(isolate);
24433 v8::Local<Value> args[] = {v8_num(42), v8_num(555)};
24434 fun->Call(env.local(), v8::Undefined(isolate), arraysize(args)(sizeof(ArraySizeHelper(args))), args)
24435 .ToLocalChecked();
24436 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24436, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24437 }
24438}
24439
24440
24441TEST(StrongObjectDelete)static void TestStrongObjectDelete(); CcTest register_test_StrongObjectDelete
(TestStrongObjectDelete, "../test/cctest/test-api.cc", "StrongObjectDelete"
, __null, true, true); static void TestStrongObjectDelete()
{
24442 i::FLAG_strong_mode = true;
24443 LocalContext env;
24444 v8::Isolate* isolate = env->GetIsolate();
24445 v8::HandleScope scope(isolate);
24446 Local<Object> obj;
24447 {
24448 v8::TryCatch try_catch(isolate);
24449 obj = Local<Object>::Cast(CompileRun(
24450 "'use strong';"
24451 "({});"));
24452 CHECK(!try_catch.HasCaught())do { if ((__builtin_expect(!!(!(!try_catch.HasCaught())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24452, "Check failed: %s."
, "!try_catch.HasCaught()"); } } while (0)
;
24453 }
24454 obj->DefineOwnProperty(env.local(), v8_str("foo"), v8_num(1), v8::None)
24455 .FromJust();
24456 obj->DefineOwnProperty(env.local(), v8_str("2"), v8_num(1), v8::None)
24457 .FromJust();
24458 CHECK(obj->HasOwnProperty(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(obj->HasOwnProperty(env.local
(), v8_str("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24458, "Check failed: %s.", "obj->HasOwnProperty(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
24459 CHECK(obj->HasOwnProperty(env.local(), v8_str("2")).FromJust())do { if ((__builtin_expect(!!(!(obj->HasOwnProperty(env.local
(), v8_str("2")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24459, "Check failed: %s.", "obj->HasOwnProperty(env.local(), v8_str(\"2\")).FromJust()"
); } } while (0)
;
24460 CHECK(!obj->Delete(env.local(), v8_str("foo")).FromJust())do { if ((__builtin_expect(!!(!(!obj->Delete(env.local(), v8_str
("foo")).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24460, "Check failed: %s.", "!obj->Delete(env.local(), v8_str(\"foo\")).FromJust()"
); } } while (0)
;
24461 CHECK(!obj->Delete(env.local(), 2).FromJust())do { if ((__builtin_expect(!!(!(!obj->Delete(env.local(), 2
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24461, "Check failed: %s.", "!obj->Delete(env.local(), 2).FromJust()"
); } } while (0)
;
24462}
24463
24464
24465static void ExtrasBindingTestRuntimeFunction(
24466 const v8::FunctionCallbackInfo<v8::Value>& args) {
24467 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (args
[0]->Int32Value(args.GetIsolate()->GetCurrentContext())
.FromJust()), "3" " " "==" " " "args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24469, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24468 3,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (args
[0]->Int32Value(args.GetIsolate()->GetCurrentContext())
.FromJust()), "3" " " "==" " " "args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24469, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24469 args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (args
[0]->Int32Value(args.GetIsolate()->GetCurrentContext())
.FromJust()), "3" " " "==" " " "args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24469, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24470 args.GetReturnValue().Set(v8_num(7));
24471}
24472
24473TEST(ExtrasFunctionSource)static void TestExtrasFunctionSource(); CcTest register_test_ExtrasFunctionSource
(TestExtrasFunctionSource, "../test/cctest/test-api.cc", "ExtrasFunctionSource"
, __null, true, true); static void TestExtrasFunctionSource()
{
24474 v8::Isolate* isolate = CcTest::isolate();
24475 v8::HandleScope handle_scope(isolate);
24476 LocalContext env;
24477
24478 v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
24479
24480 // Functions defined in extras do not expose source code.
24481 auto func = binding->Get(env.local(), v8_str("testFunctionToString"))
24482 .ToLocalChecked()
24483 .As<v8::Function>();
24484 auto undefined = v8::Undefined(isolate);
24485 auto result = func->Call(env.local(), undefined, 0, {})
24486 .ToLocalChecked()
24487 .As<v8::String>();
24488 CHECK(result->StrictEquals(v8_str("function foo() { [native code] }")))do { if ((__builtin_expect(!!(!(result->StrictEquals(v8_str
("function foo() { [native code] }")))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24488, "Check failed: %s.", "result->StrictEquals(v8_str(\"function foo() { [native code] }\"))"
); } } while (0)
;
24489
24490 // Functions defined in extras do not show up in the stack trace.
24491 auto wrapper = binding->Get(env.local(), v8_str("testStackTrace"))
24492 .ToLocalChecked()
24493 .As<v8::Function>();
24494 CHECK(env->Global()->Set(env.local(), v8_str("wrapper"), wrapper).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("wrapper"), wrapper).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24494, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"wrapper\"), wrapper).FromJust()"
); } } while (0)
;
24495 ExpectString(
24496 "function f(x) { return wrapper(x) }"
24497 "function g() { return new Error().stack; }"
24498 "f(g)",
24499 "Error\n"
24500 " at g (<anonymous>:1:58)\n"
24501 " at f (<anonymous>:1:24)\n"
24502 " at <anonymous>:1:78");
24503}
24504
24505TEST(ExtrasBindingObject)static void TestExtrasBindingObject(); CcTest register_test_ExtrasBindingObject
(TestExtrasBindingObject, "../test/cctest/test-api.cc", "ExtrasBindingObject"
, __null, true, true); static void TestExtrasBindingObject()
{
24506 v8::Isolate* isolate = CcTest::isolate();
24507 v8::HandleScope handle_scope(isolate);
24508 LocalContext env;
24509
24510 // standalone.gypi ensures we include the test-extra.js file, which should
24511 // export the tested functions.
24512 v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
24513
24514 auto func = binding->Get(env.local(), v8_str("testExtraShouldReturnFive"))
24515 .ToLocalChecked()
24516 .As<v8::Function>();
24517 auto undefined = v8::Undefined(isolate);
24518 auto result = func->Call(env.local(), undefined, 0, {})
24519 .ToLocalChecked()
24520 .As<v8::Number>();
24521 CHECK_EQ(5, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (5), (result
->Int32Value(env.local()).FromJust()), "5" " " "==" " " "result->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24521, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24522
24523 v8::Local<v8::FunctionTemplate> runtimeFunction =
24524 v8::FunctionTemplate::New(isolate, ExtrasBindingTestRuntimeFunction);
24525 binding->Set(env.local(), v8_str("runtime"),
24526 runtimeFunction->GetFunction(env.local()).ToLocalChecked())
24527 .FromJust();
24528 func = binding->Get(env.local(), v8_str("testExtraShouldCallToRuntime"))
24529 .ToLocalChecked()
24530 .As<v8::Function>();
24531 result = func->Call(env.local(), undefined, 0, {})
24532 .ToLocalChecked()
24533 .As<v8::Number>();
24534 CHECK_EQ(7, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (result
->Int32Value(env.local()).FromJust()), "7" " " "==" " " "result->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24534, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24535}
24536
24537
24538TEST(ExperimentalExtras)static void TestExperimentalExtras(); CcTest register_test_ExperimentalExtras
(TestExperimentalExtras, "../test/cctest/test-api.cc", "ExperimentalExtras"
, __null, true, true); static void TestExperimentalExtras()
{
24539 i::FLAG_experimental_extras = true;
24540
24541 v8::Isolate* isolate = CcTest::isolate();
24542 v8::HandleScope handle_scope(isolate);
24543 LocalContext env;
24544
24545 // standalone.gypi ensures we include the test-experimental-extra.js file,
24546 // which should export the tested functions.
24547 v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
24548
24549 auto func =
24550 binding->Get(env.local(), v8_str("testExperimentalExtraShouldReturnTen"))
24551 .ToLocalChecked()
24552 .As<v8::Function>();
24553 auto undefined = v8::Undefined(isolate);
24554 auto result = func->Call(env.local(), undefined, 0, {})
24555 .ToLocalChecked()
24556 .As<v8::Number>();
24557 CHECK_EQ(10, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (10), (
result->Int32Value(env.local()).FromJust()), "10" " " "=="
" " "result->Int32Value(env.local()).FromJust()")) { V8_Fatal
("../test/cctest/test-api.cc", 24557, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24558
24559 v8::Local<v8::FunctionTemplate> runtimeFunction =
24560 v8::FunctionTemplate::New(isolate, ExtrasBindingTestRuntimeFunction);
24561 binding->Set(env.local(), v8_str("runtime"),
24562 runtimeFunction->GetFunction(env.local()).ToLocalChecked())
24563 .FromJust();
24564 func = binding->Get(env.local(),
24565 v8_str("testExperimentalExtraShouldCallToRuntime"))
24566 .ToLocalChecked()
24567 .As<v8::Function>();
24568 result = func->Call(env.local(), undefined, 0, {})
24569 .ToLocalChecked()
24570 .As<v8::Number>();
24571 CHECK_EQ(7, result->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (7), (result
->Int32Value(env.local()).FromJust()), "7" " " "==" " " "result->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24571, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24572}
24573
24574
24575TEST(ExtrasUtilsObject)static void TestExtrasUtilsObject(); CcTest register_test_ExtrasUtilsObject
(TestExtrasUtilsObject, "../test/cctest/test-api.cc", "ExtrasUtilsObject"
, __null, true, true); static void TestExtrasUtilsObject()
{
24576 LocalContext context;
24577 v8::Isolate* isolate = context->GetIsolate();
24578 v8::HandleScope handle_scope(isolate);
24579
24580 LocalContext env;
24581 v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
24582
24583 auto func = binding->Get(env.local(), v8_str("testExtraCanUseUtils"))
24584 .ToLocalChecked()
24585 .As<v8::Function>();
24586 auto undefined = v8::Undefined(isolate);
24587 auto result = func->Call(env.local(), undefined, 0, {})
24588 .ToLocalChecked()
24589 .As<v8::Object>();
24590
24591 auto private_symbol = result->Get(env.local(), v8_str("privateSymbol"))
24592 .ToLocalChecked()
24593 .As<v8::Symbol>();
24594 i::Handle<i::Symbol> ips = v8::Utils::OpenHandle(*private_symbol);
24595 CHECK_EQ(true, ips->IsPrivate())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (true),
(ips->IsPrivate()), "true" " " "==" " " "ips->IsPrivate()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24595, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24596
24597 CompileRun("var result = 0; function store(x) { result = x; }");
24598 auto store = CompileRun("store").As<v8::Function>();
24599
24600 auto fulfilled_promise = result->Get(env.local(), v8_str("fulfilledPromise"))
24601 .ToLocalChecked()
24602 .As<v8::Promise>();
24603 fulfilled_promise->Then(env.local(), store).ToLocalChecked();
24604 isolate->RunMicrotasks();
24605 CHECK_EQ(1, CompileRun("result")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (CompileRun
("result")->Int32Value(env.local()).FromJust()), "1" " " "=="
" " "CompileRun(\"result\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24605, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24606
24607 auto fulfilled_promise_2 =
24608 result->Get(env.local(), v8_str("fulfilledPromise2"))
24609 .ToLocalChecked()
24610 .As<v8::Promise>();
24611 fulfilled_promise_2->Then(env.local(), store).ToLocalChecked();
24612 isolate->RunMicrotasks();
24613 CHECK_EQ(2, CompileRun("result")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (CompileRun
("result")->Int32Value(env.local()).FromJust()), "2" " " "=="
" " "CompileRun(\"result\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24613, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24614
24615 auto rejected_promise = result->Get(env.local(), v8_str("rejectedPromise"))
24616 .ToLocalChecked()
24617 .As<v8::Promise>();
24618 rejected_promise->Catch(env.local(), store).ToLocalChecked();
24619 isolate->RunMicrotasks();
24620 CHECK_EQ(3, CompileRun("result")->Int32Value(env.local()).FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (CompileRun
("result")->Int32Value(env.local()).FromJust()), "3" " " "=="
" " "CompileRun(\"result\")->Int32Value(env.local()).FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24620, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24621}
24622
24623
24624TEST(Map)static void TestMap(); CcTest register_test_Map(TestMap, "../test/cctest/test-api.cc"
, "Map", __null, true, true); static void TestMap()
{
24625 v8::Isolate* isolate = CcTest::isolate();
24626 v8::HandleScope handle_scope(isolate);
24627 LocalContext env;
24628
24629 v8::Local<v8::Map> map = v8::Map::New(isolate);
24630 CHECK(map->IsObject())do { if ((__builtin_expect(!!(!(map->IsObject())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24630, "Check failed: %s.", "map->IsObject()"
); } } while (0)
;
24631 CHECK(map->IsMap())do { if ((__builtin_expect(!!(!(map->IsMap())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24631, "Check failed: %s.", "map->IsMap()"
); } } while (0)
;
24632 CHECK(map->GetPrototype()->StrictEquals(CompileRun("Map.prototype")))do { if ((__builtin_expect(!!(!(map->GetPrototype()->StrictEquals
(CompileRun("Map.prototype")))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24632, "Check failed: %s.", "map->GetPrototype()->StrictEquals(CompileRun(\"Map.prototype\"))"
); } } while (0)
;
24633 CHECK_EQ(0U, map->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0U), (
map->Size()), "0U" " " "==" " " "map->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24633, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24634
24635 v8::Local<v8::Value> val = CompileRun("new Map([[1, 2], [3, 4]])");
24636 CHECK(val->IsMap())do { if ((__builtin_expect(!!(!(val->IsMap())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24636, "Check failed: %s.", "val->IsMap()"
); } } while (0)
;
24637 map = v8::Local<v8::Map>::Cast(val);
24638 CHECK_EQ(2U, map->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
map->Size()), "2U" " " "==" " " "map->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24638, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24639
24640 v8::Local<v8::Array> contents = map->AsArray();
24641 CHECK_EQ(4U, contents->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4U), (
contents->Length()), "4U" " " "==" " " "contents->Length()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24641, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24642 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (contents
->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>
()->Value()), "1" " " "==" " " "contents->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24644, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24643 1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (contents
->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>
()->Value()), "1" " " "==" " " "contents->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24644, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24644 contents->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (contents
->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>
()->Value()), "1" " " "==" " " "contents->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24644, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24645 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (contents
->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>
()->Value()), "2" " " "==" " " "contents->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24647, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24646 2,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (contents
->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>
()->Value()), "2" " " "==" " " "contents->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24647, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24647 contents->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (contents
->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>
()->Value()), "2" " " "==" " " "contents->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24647, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24648 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (contents
->Get(env.local(), 2).ToLocalChecked().As<v8::Int32>
()->Value()), "3" " " "==" " " "contents->Get(env.local(), 2).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24650, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24649 3,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (contents
->Get(env.local(), 2).ToLocalChecked().As<v8::Int32>
()->Value()), "3" " " "==" " " "contents->Get(env.local(), 2).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24650, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24650 contents->Get(env.local(), 2).ToLocalChecked().As<v8::Int32>()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3), (contents
->Get(env.local(), 2).ToLocalChecked().As<v8::Int32>
()->Value()), "3" " " "==" " " "contents->Get(env.local(), 2).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24650, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24651 CHECK_EQ(do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (contents
->Get(env.local(), 3).ToLocalChecked().As<v8::Int32>
()->Value()), "4" " " "==" " " "contents->Get(env.local(), 3).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24653, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24652 4,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (contents
->Get(env.local(), 3).ToLocalChecked().As<v8::Int32>
()->Value()), "4" " " "==" " " "contents->Get(env.local(), 3).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24653, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24653 contents->Get(env.local(), 3).ToLocalChecked().As<v8::Int32>()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (contents
->Get(env.local(), 3).ToLocalChecked().As<v8::Int32>
()->Value()), "4" " " "==" " " "contents->Get(env.local(), 3).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24653, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24654
24655 CHECK_EQ(2U, map->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
map->Size()), "2U" " " "==" " " "map->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24655, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24656
24657 CHECK(map->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust())do { if ((__builtin_expect(!!(!(map->Has(env.local(), v8::
Integer::New(isolate, 1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24657, "Check failed: %s.", "map->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust()"
); } } while (0)
;
24658 CHECK(map->Has(env.local(), v8::Integer::New(isolate, 3)).FromJust())do { if ((__builtin_expect(!!(!(map->Has(env.local(), v8::
Integer::New(isolate, 3)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24658, "Check failed: %s.", "map->Has(env.local(), v8::Integer::New(isolate, 3)).FromJust()"
); } } while (0)
;
24659
24660 CHECK(!map->Has(env.local(), v8::Integer::New(isolate, 2)).FromJust())do { if ((__builtin_expect(!!(!(!map->Has(env.local(), v8::
Integer::New(isolate, 2)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24660, "Check failed: %s.", "!map->Has(env.local(), v8::Integer::New(isolate, 2)).FromJust()"
); } } while (0)
;
24661 CHECK(!map->Has(env.local(), map).FromJust())do { if ((__builtin_expect(!!(!(!map->Has(env.local(), map
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24661, "Check failed: %s.", "!map->Has(env.local(), map).FromJust()"
); } } while (0)
;
24662
24663 CHECK_EQ(2, map->Get(env.local(), v8::Integer::New(isolate, 1))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (map
->Get(env.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->Int32Value(env.local()) .FromJust()), "2" " " "==" " "
"map->Get(env.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24666, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24664 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (map
->Get(env.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->Int32Value(env.local()) .FromJust()), "2" " " "==" " "
"map->Get(env.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24666, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24665 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (map
->Get(env.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->Int32Value(env.local()) .FromJust()), "2" " " "==" " "
"map->Get(env.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24666, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24666 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (map
->Get(env.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked
() ->Int32Value(env.local()) .FromJust()), "2" " " "==" " "
"map->Get(env.local(), v8::Integer::New(isolate, 1)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24666, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24667 CHECK_EQ(4, map->Get(env.local(), v8::Integer::New(isolate, 3))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (map
->Get(env.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked
() ->Int32Value(env.local()) .FromJust()), "4" " " "==" " "
"map->Get(env.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24670, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24668 .ToLocalChecked()do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (map
->Get(env.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked
() ->Int32Value(env.local()) .FromJust()), "4" " " "==" " "
"map->Get(env.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24670, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24669 ->Int32Value(env.local())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (map
->Get(env.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked
() ->Int32Value(env.local()) .FromJust()), "4" " " "==" " "
"map->Get(env.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24670, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24670 .FromJust())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (4), (map
->Get(env.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked
() ->Int32Value(env.local()) .FromJust()), "4" " " "==" " "
"map->Get(env.local(), v8::Integer::New(isolate, 3)) .ToLocalChecked() ->Int32Value(env.local()) .FromJust()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24670, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24671
24672 CHECK(map->Get(env.local(), v8::Integer::New(isolate, 42))do { if ((__builtin_expect(!!(!(map->Get(env.local(), v8::
Integer::New(isolate, 42)) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24674, "Check failed: %s."
, "map->Get(env.local(), v8::Integer::New(isolate, 42)) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
24673 .ToLocalChecked()do { if ((__builtin_expect(!!(!(map->Get(env.local(), v8::
Integer::New(isolate, 42)) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24674, "Check failed: %s."
, "map->Get(env.local(), v8::Integer::New(isolate, 42)) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
24674 ->IsUndefined())do { if ((__builtin_expect(!!(!(map->Get(env.local(), v8::
Integer::New(isolate, 42)) .ToLocalChecked() ->IsUndefined
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24674, "Check failed: %s."
, "map->Get(env.local(), v8::Integer::New(isolate, 42)) .ToLocalChecked() ->IsUndefined()"
); } } while (0)
;
24675
24676 CHECK(!map->Set(env.local(), map, map).IsEmpty())do { if ((__builtin_expect(!!(!(!map->Set(env.local(), map
, map).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24676, "Check failed: %s.", "!map->Set(env.local(), map, map).IsEmpty()"
); } } while (0)
;
24677 CHECK_EQ(3U, map->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3U), (
map->Size()), "3U" " " "==" " " "map->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24677, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24678 CHECK(map->Has(env.local(), map).FromJust())do { if ((__builtin_expect(!!(!(map->Has(env.local(), map)
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24678
, "Check failed: %s.", "map->Has(env.local(), map).FromJust()"
); } } while (0)
;
24679
24680 CHECK(map->Delete(env.local(), map).FromJust())do { if ((__builtin_expect(!!(!(map->Delete(env.local(), map
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24680, "Check failed: %s.", "map->Delete(env.local(), map).FromJust()"
); } } while (0)
;
24681 CHECK_EQ(2U, map->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
map->Size()), "2U" " " "==" " " "map->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24681, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24682 CHECK(!map->Has(env.local(), map).FromJust())do { if ((__builtin_expect(!!(!(!map->Has(env.local(), map
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24682, "Check failed: %s.", "!map->Has(env.local(), map).FromJust()"
); } } while (0)
;
24683 CHECK(!map->Delete(env.local(), map).FromJust())do { if ((__builtin_expect(!!(!(!map->Delete(env.local(), map
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24683, "Check failed: %s.", "!map->Delete(env.local(), map).FromJust()"
); } } while (0)
;
24684
24685 map->Clear();
24686 CHECK_EQ(0U, map->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0U), (
map->Size()), "0U" " " "==" " " "map->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24686, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24687}
24688
24689
24690TEST(Set)static void TestSet(); CcTest register_test_Set(TestSet, "../test/cctest/test-api.cc"
, "Set", __null, true, true); static void TestSet()
{
24691 v8::Isolate* isolate = CcTest::isolate();
24692 v8::HandleScope handle_scope(isolate);
24693 LocalContext env;
24694
24695 v8::Local<v8::Set> set = v8::Set::New(isolate);
24696 CHECK(set->IsObject())do { if ((__builtin_expect(!!(!(set->IsObject())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24696, "Check failed: %s.", "set->IsObject()"
); } } while (0)
;
24697 CHECK(set->IsSet())do { if ((__builtin_expect(!!(!(set->IsSet())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24697, "Check failed: %s.", "set->IsSet()"
); } } while (0)
;
24698 CHECK(set->GetPrototype()->StrictEquals(CompileRun("Set.prototype")))do { if ((__builtin_expect(!!(!(set->GetPrototype()->StrictEquals
(CompileRun("Set.prototype")))), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24698, "Check failed: %s.", "set->GetPrototype()->StrictEquals(CompileRun(\"Set.prototype\"))"
); } } while (0)
;
24699 CHECK_EQ(0U, set->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0U), (
set->Size()), "0U" " " "==" " " "set->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24699, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24700
24701 v8::Local<v8::Value> val = CompileRun("new Set([1, 2])");
24702 CHECK(val->IsSet())do { if ((__builtin_expect(!!(!(val->IsSet())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24702, "Check failed: %s.", "val->IsSet()"
); } } while (0)
;
24703 set = v8::Local<v8::Set>::Cast(val);
24704 CHECK_EQ(2U, set->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
set->Size()), "2U" " " "==" " " "set->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24704, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24705
24706 v8::Local<v8::Array> keys = set->AsArray();
24707 CHECK_EQ(2U, keys->Length())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
keys->Length()), "2U" " " "==" " " "keys->Length()")) {
V8_Fatal("../test/cctest/test-api.cc", 24707, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24708 CHECK_EQ(1,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (keys
->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>
()->Value()), "1" " " "==" " " "keys->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24709, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24709 keys->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (keys
->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>
()->Value()), "1" " " "==" " " "keys->Get(env.local(), 0).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24709, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24710 CHECK_EQ(2,do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (keys
->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>
()->Value()), "2" " " "==" " " "keys->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24711, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24711 keys->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>()->Value())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2), (keys
->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>
()->Value()), "2" " " "==" " " "keys->Get(env.local(), 1).ToLocalChecked().As<v8::Int32>()->Value()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24711, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24712
24713 CHECK_EQ(2U, set->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
set->Size()), "2U" " " "==" " " "set->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24713, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24714
24715 CHECK(set->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust())do { if ((__builtin_expect(!!(!(set->Has(env.local(), v8::
Integer::New(isolate, 1)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24715, "Check failed: %s.", "set->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust()"
); } } while (0)
;
24716 CHECK(set->Has(env.local(), v8::Integer::New(isolate, 2)).FromJust())do { if ((__builtin_expect(!!(!(set->Has(env.local(), v8::
Integer::New(isolate, 2)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24716, "Check failed: %s.", "set->Has(env.local(), v8::Integer::New(isolate, 2)).FromJust()"
); } } while (0)
;
24717
24718 CHECK(!set->Has(env.local(), v8::Integer::New(isolate, 3)).FromJust())do { if ((__builtin_expect(!!(!(!set->Has(env.local(), v8::
Integer::New(isolate, 3)).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24718, "Check failed: %s.", "!set->Has(env.local(), v8::Integer::New(isolate, 3)).FromJust()"
); } } while (0)
;
24719 CHECK(!set->Has(env.local(), set).FromJust())do { if ((__builtin_expect(!!(!(!set->Has(env.local(), set
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24719, "Check failed: %s.", "!set->Has(env.local(), set).FromJust()"
); } } while (0)
;
24720
24721 CHECK(!set->Add(env.local(), set).IsEmpty())do { if ((__builtin_expect(!!(!(!set->Add(env.local(), set
).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24721
, "Check failed: %s.", "!set->Add(env.local(), set).IsEmpty()"
); } } while (0)
;
24722 CHECK_EQ(3U, set->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (3U), (
set->Size()), "3U" " " "==" " " "set->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24722, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24723 CHECK(set->Has(env.local(), set).FromJust())do { if ((__builtin_expect(!!(!(set->Has(env.local(), set)
.FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24723
, "Check failed: %s.", "set->Has(env.local(), set).FromJust()"
); } } while (0)
;
24724
24725 CHECK(set->Delete(env.local(), set).FromJust())do { if ((__builtin_expect(!!(!(set->Delete(env.local(), set
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24725, "Check failed: %s.", "set->Delete(env.local(), set).FromJust()"
); } } while (0)
;
24726 CHECK_EQ(2U, set->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (2U), (
set->Size()), "2U" " " "==" " " "set->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24726, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24727 CHECK(!set->Has(env.local(), set).FromJust())do { if ((__builtin_expect(!!(!(!set->Has(env.local(), set
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24727, "Check failed: %s.", "!set->Has(env.local(), set).FromJust()"
); } } while (0)
;
24728 CHECK(!set->Delete(env.local(), set).FromJust())do { if ((__builtin_expect(!!(!(!set->Delete(env.local(), set
).FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc",
24728, "Check failed: %s.", "!set->Delete(env.local(), set).FromJust()"
); } } while (0)
;
24729
24730 set->Clear();
24731 CHECK_EQ(0U, set->Size())do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0U), (
set->Size()), "0U" " " "==" " " "set->Size()")) { V8_Fatal
("../test/cctest/test-api.cc", 24731, "Check failed: %s.", _msg
->c_str()); delete _msg; } } while (0)
;
24732}
24733
24734
24735TEST(CompatibleReceiverCheckOnCachedICHandler)static void TestCompatibleReceiverCheckOnCachedICHandler(); CcTest
register_test_CompatibleReceiverCheckOnCachedICHandler(TestCompatibleReceiverCheckOnCachedICHandler
, "../test/cctest/test-api.cc", "CompatibleReceiverCheckOnCachedICHandler"
, __null, true, true); static void TestCompatibleReceiverCheckOnCachedICHandler
()
{
24736 v8::Isolate* isolate = CcTest::isolate();
24737 v8::HandleScope scope(isolate);
24738 v8::Local<v8::FunctionTemplate> parent = FunctionTemplate::New(isolate);
24739 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, parent);
24740 auto returns_42 =
24741 v8::FunctionTemplate::New(isolate, Returns42, Local<Value>(), signature);
24742 parent->PrototypeTemplate()->SetAccessorProperty(v8_str("age"), returns_42);
24743 v8::Local<v8::FunctionTemplate> child = v8::FunctionTemplate::New(isolate);
24744 child->Inherit(parent);
24745 LocalContext env;
24746 CHECK(env->Global()do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Child"), child->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24749, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Child\"), child->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
24747 ->Set(env.local(), v8_str("Child"),do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Child"), child->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24749, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Child\"), child->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
24748 child->GetFunction(env.local()).ToLocalChecked())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Child"), child->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24749, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Child\"), child->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
24749 .FromJust())do { if ((__builtin_expect(!!(!(env->Global() ->Set(env
.local(), v8_str("Child"), child->GetFunction(env.local())
.ToLocalChecked()) .FromJust())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24749, "Check failed: %s.", "env->Global() ->Set(env.local(), v8_str(\"Child\"), child->GetFunction(env.local()).ToLocalChecked()) .FromJust()"
); } } while (0)
;
24750
24751 // Make sure there's a compiled stub for "Child.prototype.age" in the cache.
24752 CompileRun(
24753 "var real = new Child();\n"
24754 "for (var i = 0; i < 3; ++i) {\n"
24755 " real.age;\n"
24756 "}\n");
24757
24758 // Check that the cached stub is never used.
24759 ExpectInt32(
24760 "var fake = Object.create(Child.prototype);\n"
24761 "var result = 0;\n"
24762 "function test(d) {\n"
24763 " if (d == 3) return;\n"
24764 " try {\n"
24765 " fake.age;\n"
24766 " result = 1;\n"
24767 " } catch (e) {\n"
24768 " }\n"
24769 " test(d+1);\n"
24770 "}\n"
24771 "test(0);\n"
24772 "result;\n",
24773 0);
24774}
24775
24776class FutexInterruptionThread : public v8::base::Thread {
24777 public:
24778 explicit FutexInterruptionThread(v8::Isolate* isolate)
24779 : Thread(Options("FutexInterruptionThread")), isolate_(isolate) {}
24780
24781 virtual void Run() {
24782 // Wait a bit before terminating.
24783 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100));
24784 isolate_->TerminateExecution();
24785 }
24786
24787 private:
24788 v8::Isolate* isolate_;
24789};
24790
24791
24792TEST(FutexInterruption)static void TestFutexInterruption(); CcTest register_test_FutexInterruption
(TestFutexInterruption, "../test/cctest/test-api.cc", "FutexInterruption"
, __null, true, true); static void TestFutexInterruption()
{
24793 i::FLAG_harmony_sharedarraybuffer = true;
24794 v8::Isolate* isolate = CcTest::isolate();
24795 v8::HandleScope scope(isolate);
24796 LocalContext env;
24797
24798 FutexInterruptionThread timeout_thread(isolate);
24799
24800 v8::TryCatch try_catch(CcTest::isolate());
24801 timeout_thread.Start();
24802
24803 CompileRun(
24804 "var ab = new SharedArrayBuffer(4);"
24805 "var i32a = new Int32Array(ab);"
24806 "Atomics.futexWait(i32a, 0, 0);");
24807 CHECK(try_catch.HasTerminated())do { if ((__builtin_expect(!!(!(try_catch.HasTerminated())), 0
))) { V8_Fatal("../test/cctest/test-api.cc", 24807, "Check failed: %s."
, "try_catch.HasTerminated()"); } } while (0)
;
24808 timeout_thread.Join();
24809}
24810
24811
24812TEST(EstimatedContextSize)static void TestEstimatedContextSize(); CcTest register_test_EstimatedContextSize
(TestEstimatedContextSize, "../test/cctest/test-api.cc", "EstimatedContextSize"
, __null, true, true); static void TestEstimatedContextSize()
{
24813 v8::Isolate* isolate = CcTest::isolate();
24814 v8::HandleScope scope(isolate);
24815 LocalContext env;
24816 CHECK(50000 < env->EstimatedSize())do { if ((__builtin_expect(!!(!(50000 < env->EstimatedSize
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24816, "Check failed: %s."
, "50000 < env->EstimatedSize()"); } } while (0)
;
24817}
24818
24819
24820static int nb_uncaught_exception_callback_calls = 0;
24821
24822
24823bool NoAbortOnUncaughtException(v8::Isolate* isolate) {
24824 ++nb_uncaught_exception_callback_calls;
24825 return false;
24826}
24827
24828
24829TEST(AbortOnUncaughtExceptionNoAbort)static void TestAbortOnUncaughtExceptionNoAbort(); CcTest register_test_AbortOnUncaughtExceptionNoAbort
(TestAbortOnUncaughtExceptionNoAbort, "../test/cctest/test-api.cc"
, "AbortOnUncaughtExceptionNoAbort", __null, true, true); static
void TestAbortOnUncaughtExceptionNoAbort()
{
24830 v8::Isolate* isolate = CcTest::isolate();
24831 v8::HandleScope handle_scope(isolate);
24832 v8::Local<v8::ObjectTemplate> global_template =
24833 v8::ObjectTemplate::New(isolate);
24834 LocalContext env(NULL__null, global_template);
24835
24836 i::FLAG_abort_on_uncaught_exception = true;
24837 isolate->SetAbortOnUncaughtExceptionCallback(NoAbortOnUncaughtException);
24838
24839 CompileRun("function boom() { throw new Error(\"boom\") }");
24840
24841 v8::Local<v8::Object> global_object = env->Global();
24842 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
24843 global_object->Get(env.local(), v8_str("boom")).ToLocalChecked());
24844
24845 CHECK(foo->Call(env.local(), global_object, 0, NULL).IsEmpty())do { if ((__builtin_expect(!!(!(foo->Call(env.local(), global_object
, 0, __null).IsEmpty())), 0))) { V8_Fatal("../test/cctest/test-api.cc"
, 24845, "Check failed: %s.", "foo->Call(env.local(), global_object, 0, NULL).IsEmpty()"
); } } while (0)
;
24846
24847 CHECK_EQ(1, nb_uncaught_exception_callback_calls)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (1), (nb_uncaught_exception_callback_calls
), "1" " " "==" " " "nb_uncaught_exception_callback_calls")) {
V8_Fatal("../test/cctest/test-api.cc", 24847, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24848}
24849
24850
24851TEST(AccessCheckedIsConcatSpreadable)static void TestAccessCheckedIsConcatSpreadable(); CcTest register_test_AccessCheckedIsConcatSpreadable
(TestAccessCheckedIsConcatSpreadable, "../test/cctest/test-api.cc"
, "AccessCheckedIsConcatSpreadable", __null, true, true); static
void TestAccessCheckedIsConcatSpreadable()
{
24852 v8::Isolate* isolate = CcTest::isolate();
24853 HandleScope scope(isolate);
24854 LocalContext env;
24855
24856 // Object with access check
24857 Local<ObjectTemplate> spreadable_template = v8::ObjectTemplate::New(isolate);
24858 spreadable_template->SetAccessCheckCallback(AccessBlocker);
24859 spreadable_template->Set(v8::Symbol::GetIsConcatSpreadable(isolate),
24860 v8::Boolean::New(isolate, true));
24861 Local<Object> object =
24862 spreadable_template->NewInstance(env.local()).ToLocalChecked();
24863
24864 allowed_access = true;
24865 CHECK(env->Global()->Set(env.local(), v8_str("object"), object).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("object"), object).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24865, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"object\"), object).FromJust()"
); } } while (0)
;
24866 object->Set(env.local(), v8_str("length"), v8_num(2)).FromJust();
24867 object->Set(env.local(), 0U, v8_str("a")).FromJust();
24868 object->Set(env.local(), 1U, v8_str("b")).FromJust();
24869
24870 // Access check is allowed, and the object is spread
24871 CompileRun("var result = [].concat(object)");
24872 ExpectTrue("Array.isArray(result)");
24873 ExpectString("result[0]", "a");
24874 ExpectString("result[1]", "b");
24875 ExpectTrue("result.length === 2");
24876 ExpectTrue("object[Symbol.isConcatSpreadable]");
24877
24878 // If access check fails, the value of @@isConcatSpreadable is ignored
24879 allowed_access = false;
24880 CompileRun("var result = [].concat(object)");
24881 ExpectTrue("Array.isArray(result)");
24882 ExpectTrue("result[0] === object");
24883 ExpectTrue("result.length === 1");
24884 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined");
24885}
24886
24887
24888TEST(AccessCheckedToStringTag)static void TestAccessCheckedToStringTag(); CcTest register_test_AccessCheckedToStringTag
(TestAccessCheckedToStringTag, "../test/cctest/test-api.cc", "AccessCheckedToStringTag"
, __null, true, true); static void TestAccessCheckedToStringTag
()
{
24889 i::FLAG_harmony_tostring = true;
24890 v8::Isolate* isolate = CcTest::isolate();
24891 HandleScope scope(isolate);
24892 LocalContext env;
24893
24894 // Object with access check
24895 Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate);
24896 object_template->SetAccessCheckCallback(AccessBlocker);
24897 Local<Object> object =
24898 object_template->NewInstance(env.local()).ToLocalChecked();
24899
24900 allowed_access = true;
24901 env->Global()->Set(env.local(), v8_str("object"), object).FromJust();
24902 object->Set(env.local(), v8::Symbol::GetToStringTag(isolate), v8_str("hello"))
24903 .FromJust();
24904
24905 // Access check is allowed, and the toStringTag is read
24906 CompileRun("var result = Object.prototype.toString.call(object)");
24907 ExpectString("result", "[object hello]");
24908 ExpectString("object[Symbol.toStringTag]", "hello");
24909
24910 // ToString through the API should succeed too.
24911 String::Utf8Value result_allowed(
24912 object->ObjectProtoToString(env.local()).ToLocalChecked());
24913 CHECK_EQ(0, strcmp(*result_allowed, "[object hello]"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*result_allowed, "[object hello]")), "0" " " "==" " " "strcmp(*result_allowed, \"[object hello]\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 24913, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24914
24915 // If access check fails, the value of @@toStringTag is ignored
24916 allowed_access = false;
24917 CompileRun("var result = Object.prototype.toString.call(object)");
24918 ExpectString("result", "[object Object]");
24919 ExpectTrue("object[Symbol.toStringTag] === undefined");
24920
24921 // ToString through the API should also fail.
24922 String::Utf8Value result_denied(
24923 object->ObjectProtoToString(env.local()).ToLocalChecked());
24924 CHECK_EQ(0, strcmp(*result_denied, "[object Object]"))do { if (std::string* _msg = ::v8::base::CheckEQImpl( (0), (strcmp
(*result_denied, "[object Object]")), "0" " " "==" " " "strcmp(*result_denied, \"[object Object]\")"
)) { V8_Fatal("../test/cctest/test-api.cc", 24924, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24925}
24926
24927
24928TEST(ObjectTemplateIntrinsics)static void TestObjectTemplateIntrinsics(); CcTest register_test_ObjectTemplateIntrinsics
(TestObjectTemplateIntrinsics, "../test/cctest/test-api.cc", "ObjectTemplateIntrinsics"
, __null, true, true); static void TestObjectTemplateIntrinsics
()
{
24929 v8::Isolate* isolate = CcTest::isolate();
24930 v8::HandleScope scope(isolate);
24931 LocalContext env;
24932
24933 Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate);
24934 object_template->SetIntrinsicDataProperty(v8_str("values"),
24935 v8::kArrayProto_values);
24936 Local<Object> object =
24937 object_template->NewInstance(env.local()).ToLocalChecked();
24938
24939 CHECK(env->Global()->Set(env.local(), v8_str("obj1"), object).FromJust())do { if ((__builtin_expect(!!(!(env->Global()->Set(env.
local(), v8_str("obj1"), object).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24939, "Check failed: %s.", "env->Global()->Set(env.local(), v8_str(\"obj1\"), object).FromJust()"
); } } while (0)
;
24940 ExpectString("typeof obj1.values", "function");
24941
24942 auto values = Local<Function>::Cast(
24943 object->Get(env.local(), v8_str("values")).ToLocalChecked());
24944 auto fn = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values));
24945 auto ctx = v8::Utils::OpenHandle(*env.local());
24946 CHECK_EQ(fn->GetCreationContext(), *ctx)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (fn->
GetCreationContext()), (*ctx), "fn->GetCreationContext()" " "
"==" " " "*ctx")) { V8_Fatal("../test/cctest/test-api.cc", 24946
, "Check failed: %s.", _msg->c_str()); delete _msg; } } while
(0)
;
24947
24948 {
24949 LocalContext env2;
24950 Local<Object> object2 =
24951 object_template->NewInstance(env2.local()).ToLocalChecked();
24952 CHECK(do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
.local(), v8_str("obj2"), object2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24953, "Check failed: %s.", "env2->Global()->Set(env2.local(), v8_str(\"obj2\"), object2).FromJust()"
); } } while (0)
24953 env2->Global()->Set(env2.local(), v8_str("obj2"), object2).FromJust())do { if ((__builtin_expect(!!(!(env2->Global()->Set(env2
.local(), v8_str("obj2"), object2).FromJust())), 0))) { V8_Fatal
("../test/cctest/test-api.cc", 24953, "Check failed: %s.", "env2->Global()->Set(env2.local(), v8_str(\"obj2\"), object2).FromJust()"
); } } while (0)
;
24954 ExpectString("typeof obj2.values", "function");
24955 CHECK_NE(*object->Get(env2.local(), v8_str("values")).ToLocalChecked(),do { if (std::string* _msg = ::v8::base::CheckNEImpl( (*object
->Get(env2.local(), v8_str("values")).ToLocalChecked()), (
*object2->Get(env2.local(), v8_str("values")).ToLocalChecked
()), "*object->Get(env2.local(), v8_str(\"values\")).ToLocalChecked()"
" " "!=" " " "*object2->Get(env2.local(), v8_str(\"values\")).ToLocalChecked()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24956, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
24956 *object2->Get(env2.local(), v8_str("values")).ToLocalChecked())do { if (std::string* _msg = ::v8::base::CheckNEImpl( (*object
->Get(env2.local(), v8_str("values")).ToLocalChecked()), (
*object2->Get(env2.local(), v8_str("values")).ToLocalChecked
()), "*object->Get(env2.local(), v8_str(\"values\")).ToLocalChecked()"
" " "!=" " " "*object2->Get(env2.local(), v8_str(\"values\")).ToLocalChecked()"
)) { V8_Fatal("../test/cctest/test-api.cc", 24956, "Check failed: %s."
, _msg->c_str()); delete _msg; } } while (0)
;
24957
24958 auto values2 = Local<Function>::Cast(
24959 object2->Get(env2.local(), v8_str("values")).ToLocalChecked());
24960 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2));
24961 auto ctx2 = v8::Utils::OpenHandle(*env2.local());
24962 CHECK_EQ(fn2->GetCreationContext(), *ctx2)do { if (std::string* _msg = ::v8::base::CheckEQImpl( (fn2->
GetCreationContext()), (*ctx2), "fn2->GetCreationContext()"
" " "==" " " "*ctx2")) { V8_Fatal("../test/cctest/test-api.cc"
, 24962, "Check failed: %s.", _msg->c_str()); delete _msg;
} } while (0)
;
24963 }
24964}
24965
24966
24967TEST(Proxy)static void TestProxy(); CcTest register_test_Proxy(TestProxy
, "../test/cctest/test-api.cc", "Proxy", __null, true, true);
static void TestProxy()
{
24968 i::FLAG_harmony_proxies = true;
24969 LocalContext context;
24970 v8::Isolate* isolate = CcTest::isolate();
24971 v8::HandleScope scope(isolate);
24972 v8::Local<v8::Object> target = CompileRun("({})").As<v8::Object>();
24973 v8::Local<v8::Object> handler = CompileRun("({})").As<v8::Object>();
24974
24975 v8::Local<v8::Proxy> proxy =
24976 v8::Proxy::New(context.local(), target, handler).ToLocalChecked();
24977 CHECK(proxy->IsProxy())do { if ((__builtin_expect(!!(!(proxy->IsProxy())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 24977, "Check failed: %s."
, "proxy->IsProxy()"); } } while (0)
;
24978 CHECK(!target->IsProxy())do { if ((__builtin_expect(!!(!(!target->IsProxy())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24978, "Check failed: %s."
, "!target->IsProxy()"); } } while (0)
;
24979 CHECK(!proxy->IsRevoked())do { if ((__builtin_expect(!!(!(!proxy->IsRevoked())), 0))
) { V8_Fatal("../test/cctest/test-api.cc", 24979, "Check failed: %s."
, "!proxy->IsRevoked()"); } } while (0)
;
24980 CHECK(proxy->GetTarget()->SameValue(target))do { if ((__builtin_expect(!!(!(proxy->GetTarget()->SameValue
(target))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24980
, "Check failed: %s.", "proxy->GetTarget()->SameValue(target)"
); } } while (0)
;
24981 CHECK(proxy->GetHandler()->SameValue(handler))do { if ((__builtin_expect(!!(!(proxy->GetHandler()->SameValue
(handler))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24981
, "Check failed: %s.", "proxy->GetHandler()->SameValue(handler)"
); } } while (0)
;
24982
24983 proxy->Revoke();
24984 CHECK(proxy->IsProxy())do { if ((__builtin_expect(!!(!(proxy->IsProxy())), 0))) {
V8_Fatal("../test/cctest/test-api.cc", 24984, "Check failed: %s."
, "proxy->IsProxy()"); } } while (0)
;
24985 CHECK(!target->IsProxy())do { if ((__builtin_expect(!!(!(!target->IsProxy())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24985, "Check failed: %s."
, "!target->IsProxy()"); } } while (0)
;
24986 CHECK(proxy->IsRevoked())do { if ((__builtin_expect(!!(!(proxy->IsRevoked())), 0)))
{ V8_Fatal("../test/cctest/test-api.cc", 24986, "Check failed: %s."
, "proxy->IsRevoked()"); } } while (0)
;
24987 CHECK(proxy->GetTarget()->SameValue(target))do { if ((__builtin_expect(!!(!(proxy->GetTarget()->SameValue
(target))), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24987
, "Check failed: %s.", "proxy->GetTarget()->SameValue(target)"
); } } while (0)
;
24988 CHECK(proxy->GetHandler()->IsNull())do { if ((__builtin_expect(!!(!(proxy->GetHandler()->IsNull
())), 0))) { V8_Fatal("../test/cctest/test-api.cc", 24988, "Check failed: %s."
, "proxy->GetHandler()->IsNull()"); } } while (0)
;
24989}